Meteor Latency
Installation
$ meteor add mikael:latency
Usage
1Meteor.latency(amount);
The amount
is an optional integer for how much latency to introduce. You should probably keep amount
to 5 or lower.
Example
1 2// BOTH SERVER AND CLIENT 3Meteor.methods({ 4 myMethod: function () { 5 6 // Add latency if we're on the server 7 if (!this.isSimulation) { 8 Meteor.latency(2); 9 } 10 return 'result'; 11 } 12}); 13 14// CLIENT 15Meteor.call('myMethod', function (error, result) { 16 console.log(result); 17});
Background
Found myself writing a bogus loop quite a bit when checking latency compensation on login forms, etc., for my Meteor projects. Inspired by @cmather's meteor-methods demo.