javascript - Showing alerts when Meteor user is updated -
i working on meteor application. occasionally, server updates current user data external database. when happens, display alert on whatever page of application open on client side. know meteor.user gets updated automatically on client, clueless how , application monitor user changes , react them. ideas on this?
the user update triggered via post server:
router.map(function() { this.route('/reload_user', {where: 'server'}).post(function() { var data = this.request.body; var user = meteor.users.findone({ "profile.id": data.id }); var data = account.getaccountinfo(apikey, secretkey); meteor.users.update(user._id, { $set: { "profile.paywall": data.paywall, } }); this.response.end(); });
on server side, want expose publication user collection. on client, want auto subscribe publication , handle changed event:
meteor.autosubscribe(function() { meteor.users.find().observe({ changed: function(item) { alert(item); } }); });
Comments
Post a Comment