mercredi 31 décembre 2014

Meteor: Tracker.autorun isn't running on user collection change?


I'm using this package to manage Facebook data as Collections in Meteor. Since a FacebookCollection can't be defined until the user is logged in with Facebook, this ticket describes a method to do so automatically; I've been trying it like so:


/lib/collections.js



Tracker.autorun(_.bind(function(){
var user = this.user;
if (user && user.services && user.services.facebook && !Friends){
Friends = FacebookCollections.getFriends("me",["id","name"],100);
}
}),this);


Using some log statements, I see this run only once, early on when user is still undefined, but never again. I suspect that this isn't being re-run because it's not referencing a reactive data source, i.e. the User collection, but I'm not quite sure what to do here to get this to work.


Note: the example in the ticket uses Meteor.user(), however, this gives the error: Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.





Aucun commentaire:

Enregistrer un commentaire