Created
April 26, 2017 17:30
-
-
Save sakulstra/62d69032a57be530c3a004682ab007b7 to your computer and use it in GitHub Desktop.
using mobx for an infinite scroll with meteor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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