Skip to content

Commit

Permalink
armAndWait out of test
Browse files Browse the repository at this point in the history
  • Loading branch information
gschmidt committed Mar 17, 2012
1 parent c946fc1 commit 5c72fca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 11 additions & 0 deletions packages/livedata/writefence.js
Expand Up @@ -57,6 +57,17 @@ _.extend(Meteor._WriteFence.prototype, {
self.completion_callbacks.push(func);
},

// Convenience function. Arms the fence, then blocks until it fires.
armAndWait: function () {
var self = this;
var future = new Future;
self.onAllCommitted(function () {
future['return']();
});
self.arm();
future.wait();
},

_maybeFire: function () {
var self = this;
if (self.fired)
Expand Down
7 changes: 1 addition & 6 deletions packages/mongo-livedata/mongo_livedata_tests.js
Expand Up @@ -63,12 +63,7 @@ Tinytest.add("mongo-livedata - basics", function (test) {
} else {
var fence = new Meteor._WriteFence;
Meteor._CurrentWriteFence.withValue(fence, f);
var future = new Future;
fence.onAllCommitted(function () {
future['return']();
});
fence.arm();
future.wait();
fence.armAndWait();
}

if (!(expected instanceof Array))
Expand Down

0 comments on commit 5c72fca

Please sign in to comment.