Best pattern for pagination for Meteor

前端 未结 2 1243
攒了一身酷
攒了一身酷 2020-12-14 12:53

Pattern for pagination is currently on a after 1.0 roadmap for Meteor. Are there any examples or suggestions how to do it now? So how to nicely do an infinite scroll by subs

2条回答
  •  一个人的身影
    2020-12-14 13:24

    There is a package on atmosphere.meteor.com for pagination that should get you started

    • https://github.com/egtann/meteor-pagination (Pagination)
    • https://github.com/tmeasday/meteor-paginated-subscription (Pagination with publish)

    The second one actually sends down one page of data at a go instead of all the data at once so if you have loads of data it might help with that. With the infinite scroll you would have to attach a manual scroll listener and put in the new data by increasing the size of a page as you scroll down (not specifically moving to page 2).

    I'm a bit unsure on what pattern to use specifically because using page size might be a bit troublesome unless you're able to get it to work right with reactivity which should be possible if you're able to seperate your {{#each}} block helpers so that its for each scroll down, perhaps using Meteor.render so that the entire set of data already available isn't re-rendered.

    It might also work if you put the data in div block containing a scroll overflow instead of the above so that it does re-render but their position in the scroll remains the same, in effect making the re-render unnoticable.

提交回复
热议问题