Fork me on GitHub
#re-frame
<
2021-07-21
>
kennytilton00:07:02

The thing is, you do not really even want a subscription on an individual IDs: you do want to see them all. Your code should look like that anyway. And I believe other TodoMVC requirements specify changes when all-complete, so the bulk all-complete? will save recomputation if done once in the signal graph.

Felipe Marques12:07:35

Hi, Kenny, thanks for the answer. The dynamic subscription seems to do the trick. But the docs seems do imply that I shouldn't need it. 😓 Giving you more details about my use case, I have a form that act as a container of sub-forms. Based on the value of the first input field, I may render one or more sub-forms, which will have an ID. I want to have a subscription that provides a complete view of the form (including its subform). So I would basically subscribe to the sub-form data based to a value in the DB. So this kind of drives me to the dynamic-subscription solution. But should I be using the form-1 with two subscriptions depending on each other as I did in the example? (I'm also more inclined to have a subscription combing the info, because I can write tests against it without worrying about the view.)

kennytilton12:07:59

I would just have a subscription that delivers the form and all its sub-forms and pick and choose the info I want from the whole wodge. Are you worried about performance?

Felipe Marques12:07:21

No, more about semantics and readability. Thanks for the inputs!

p-himik06:07:06

Notice how that document on dynamic subscriptions states how it's outdated and is probably unnecessary. The code above is absolutely fine. But all-complete-list should probably become a separate subscription so there's less logic in the view.