javascript - How do I simulate a slow Meteor publication? -
javascript - How do I simulate a slow Meteor publication? -
i'm trying simulate publication doing bunch of work , taking long time homecoming cursor.
my publish method has forced sleep (using future), app displays only
loading...here's publication:
meteor.publish('people', function() { future = npm.require('fibers/future'); var future = new future(); //simulate long pause settimeout(function() { // update: coding error here. line needs // future.return(people.find()); // see accepted reply alternative, too: // meteor._sleepforms(2000); homecoming people.find(); }, 2000); //wait future.return homecoming future.wait(); }); and router:
router.configure({ layouttemplate: 'layout', loadingtemplate: 'loading' }); router.map(function() { homecoming this.route('home', { path: '/', waiton: function() { homecoming [meteor.subscribe('people')]; }, data: function() { homecoming { 'people': people.find() }; } }); }); router.onbeforeaction('loading'); full source code: https://gitlab.com/meonkeys/meteor-simulate-slow-publication
the easiest way utilize undocumented meteor._sleepforms function so:
meteor.publish('people', function() { meteor._sleepforms(2000); homecoming people.find(); }); javascript meteor
Comments
Post a Comment