meteor-flux-helpers
meteor-flux-helpers copied to clipboard
Meteor package with general flux helpers
Meteor Flux Helpers
These helpers are designed to work with any flux implementation by allowing your action method to be passed in.
Installation
meteor add skinnygeek1010:flux-helpers
#### Watch a Collection for changes When using flux you don't depend on the data in your templates to do the re-rendering. This turns out to be good because it let's us have more control of re-renders. The dispatcher will batch up these changes for minimal rendering.
trackCollection(yourCollection, yourActionCallback);
// watch collections on Minimongo cache and trigger action on change
trackCollection(Meteor.users, CollectionActions.usersChanged);
trackCollection(Posts, CollectionActions.postsChanged);
#### Watch a Collection Cursor for changes
trackCollectionCursor(yourCollection.find(criteria), yourActionCallback);
// watch specific collection cursors on Minimongo cache and trigger action on change
trackCollectionCursor(Meteor.users.find({ foo: 'bar' }), CollectionActions.usersChanged);
trackCollectionCursor(Posts.find({ foo: 'bar' }), CollectionActions.postsChanged);
#### Watch the viewer's user object for changes
trackViewer(yourActionCallback);
Use this to listen for changes on just the viewer's user object. If you want to listen to all users, use the helper above instead.
// watch the logged in user and trigger an action on change
trackViewer(CollectionActions.viewerChanged);
Confused on how to use these to get your app working? Checkout the leaderboard flux example
Find yourself writing more boilerplate for flux? Open an issue!