Reputation: 3415
I'm learning so if this is a silly question feel free to let me know. My question relates to subscription and where you should subscribe. Let me be more specific with an example.
files
template.html
templatePieceOne.html
templatePieceTwo.html
In this example we have a template.html that will render using two separate template pieces. The template pieces might be used else where on the website. Is it better to subscribe at the top level template.html, template.js, or should the template pieces each have their own subscription.
If this doesn't make sense please let me know.
Upvotes: 1
Views: 30
Reputation: 19544
You definitely shouldn't subscribe in every template. Instead, you should decide which templates correspond to an independent part of the application, i.e. a view, modal or widget. Those templates should be responsible for subscribing to, managing and passing down their data. This way you'll be able to see easily which part of the application is active at any given moment and what it subscribes to.
I recommend the following article on presentation and container components. Even if you're using Blaze instead of React the idea is still valid.
Upvotes: 1