Skip to content

Instantly share code, notes, and snippets.

@sakulstra
Created April 26, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakulstra/62d69032a57be530c3a004682ab007b7 to your computer and use it in GitHub Desktop.
Save sakulstra/62d69032a57be530c3a004682ab007b7 to your computer and use it in GitHub Desktop.
using mobx for an infinite scroll with meteor
class Store{
@observable limit = 20
@observable isLoading = false
@observable data = observable({})
constructor() {
autorun(() => this.subscribe())
}
subscribe = () => {
// subscribe using the current limit and push result into the array
// you should store the handle and dispose on onMount
}
increaseLimit = () => {
// you could do this more clever
// e.g. check if data contains less entries then limit - then you know you already have all results
this.limit += 10
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment