iron router - Meteor - How do I automatically redirect user to page when data changes -
i writing meteor app takes in external data machine (think iot) , displays lots of charts, graphs, etc. far good. there various pages in application (one per graph type far). data being fed in "real-time", there situation (normal) data "set" gets totally reset. i.e. data no longer valid. when happens, want redirect user "home" page regardless of (well, except home page).
i hoping make "global" item, don't want overhead. noticed iron:router (that using) has ondata()method seems bit -- high overhead -- since it's 1 piece of data indicates reset.
since each page rather "independent" , user can stay on page long time (the graphs auto-update underlying data changes) , i'm not sure iron:router best approach @ all.
this meteor 1.0.x btw.
just looking clean "proper" meteor way handle this. put check in redisplay logic of each page, think more abstracted (read: global) approach more long-term friendly (so if add more pages of graphs automatically still works) ..
thanks!
this job cursor.observechanges
http://docs.meteor.com/#/full/observe_changes set collection servers "reset notification" broadcasts users when new notification inserted.
on client:
criteria = {somecriteria: true}; query = resetnotificationcollection.find(criteria) var handle = query.observechanges({ added: function (id, user) { router.go('home'); } });
whenever reset happens:
notification = { time: new date(), whateveryouwanthere: 'useful info' } resetnotificationcollection.insert notification
on insert, clients observing changes on collection respond efficient little ddp message.
Comments
Post a Comment