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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -