meteor - Deps.autorun based on chaning value in database. -
i seek deps.autorun function based on changing value in database. goal run function everytime value changes, instead of having create lot of method calls in code.
with session.set , session.get setting deps.autorun gives no problems , it's pretty straightforward.
my code (simplified);
newnotification = function() { var game = games.find({}, {fields: {lastaction: 1}}).fetch(); console.log('log: ' + game); // [object, object] console.log('log: ' + game._id); undefined console.log('log: ' + game.lastaction); undefined } deps.autorun(function() { newnotification(); })
how accomplish this? there other (better) way this, working session objects example?
you should take @ observechanges
in meteor documentation. seek this.
games.find({}, { fields: { lastaction: 1 } }).observechanges({ changed: function(id, fields) { newnotification(); } });
meteor
No comments:
Post a Comment