-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Related to #2
Edit: This is an untested pattern but it seems like it might work.
- in topic route, subscribe to a static number of comments (e.g 15) -- the main purpose is just to allow fast-render to work (also subs manager)
- handle all other subscriptions within the topic template: use an autorun with a reactiveVar (holding the "limit" of comments) defaulted to same number as the amount fast-rendered (e.g 15)
- invalidating autorun (e.g changing the limit with infinite scrolling) will cause subscription to more docs
Even for things like showing the list of comments in a topic, subscribing at the route-level is problematic. When infinite scrolling causes Session.get('itemsLimit') to change, the layout-related calls (e.g this.render('nav', { to: 'nav' })) are re-run so the entire page 'flashes' and shoots back up to the top. Handling the topic comments as a component is a convenient way to fix this.
Alternatively, for things like topic lists that don't seem to fit well within template subs (or that we want to handle with subs-manager or fast-render), we could store the limit on the controller and handle subscriptions as usual. The drawback is that rendering any templates outside of this.ready() block in the action hook will cause the page 'flash' issue so there is less flexibility with the loading template.
Maybe use nested layouts, where the wrapping layout won't rerun? (e.g things like the container and the nav shouldn't have to be rerendered)