Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle subscriptions at the template level for components like comment replies #6

Open
erasaur opened this issue Apr 28, 2015 · 0 comments

Comments

@erasaur
Copy link
Owner

erasaur commented Apr 28, 2015

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)

erasaur added a commit that referenced this issue Apr 28, 2015
…oxes). This can probably be fixed if we don't have the Session holding the shown replies as a dependency in the route subscriptions, since that is triggering a re-run of the commentReplies subscription. One way to do it is to handle the comment replies subs per comment reply box (see #6)
erasaur added a commit that referenced this issue Apr 28, 2015
…lling on home page #9, handle subs with controller state #6
erasaur added a commit that referenced this issue Apr 28, 2015
erasaur added a commit that referenced this issue May 2, 2015
erasaur added a commit that referenced this issue May 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant