mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
De-singletonize InvalidationCrossbar
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
DDPServer._InvalidationCrossbar = function () {
|
||||
// A "crossbar" is a class that provides structured notification registration.
|
||||
// The "invalidation crossbar" is a specific instance used by the DDP server to
|
||||
// implement write fence notifications.
|
||||
|
||||
DDPServer._Crossbar = function () {
|
||||
var self = this;
|
||||
|
||||
self.next_id = 1;
|
||||
@@ -7,7 +11,7 @@ DDPServer._InvalidationCrossbar = function () {
|
||||
self.listeners = {};
|
||||
};
|
||||
|
||||
_.extend(DDPServer._InvalidationCrossbar.prototype, {
|
||||
_.extend(DDPServer._Crossbar.prototype, {
|
||||
// Listen for notification that match 'trigger'. A notification
|
||||
// matches if it has the key-value pairs in trigger as a
|
||||
// subset. When a notification matches, call 'callback', passing two
|
||||
@@ -57,7 +61,7 @@ _.extend(DDPServer._InvalidationCrossbar.prototype, {
|
||||
|
||||
if (onComplete)
|
||||
onComplete = Meteor.bindEnvironment(onComplete, function (e) {
|
||||
Meteor._debug("Exception in InvalidationCrossbar fire complete " +
|
||||
Meteor._debug("Exception in Crossbar fire complete " +
|
||||
"callback", e.stack);
|
||||
});
|
||||
|
||||
@@ -99,5 +103,4 @@ _.extend(DDPServer._InvalidationCrossbar.prototype, {
|
||||
}
|
||||
});
|
||||
|
||||
// singleton
|
||||
DDPServer._InvalidationCrossbar = new DDPServer._InvalidationCrossbar;
|
||||
DDPServer._InvalidationCrossbar = new DDPServer._Crossbar;
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
// deep meaning to the matching function, and it could be changed later
|
||||
// as long as it preserves that property.
|
||||
Tinytest.add('livedata - crossbar', function (test) {
|
||||
test.isTrue(DDPServer._InvalidationCrossbar._matches(
|
||||
{collection: "C"}, {collection: "C"}));
|
||||
test.isTrue(DDPServer._InvalidationCrossbar._matches(
|
||||
{collection: "C", id: "X"}, {collection: "C"}));
|
||||
test.isTrue(DDPServer._InvalidationCrossbar._matches(
|
||||
{collection: "C"}, {collection: "C", id: "X"}));
|
||||
test.isTrue(DDPServer._InvalidationCrossbar._matches(
|
||||
{collection: "C", id: "X"}, {collection: "C"}));
|
||||
var crossbar = new DDPServer._Crossbar;
|
||||
test.isTrue(crossbar._matches({collection: "C"},
|
||||
{collection: "C"}));
|
||||
test.isTrue(crossbar._matches({collection: "C", id: "X"},
|
||||
{collection: "C"}));
|
||||
test.isTrue(crossbar._matches({collection: "C"},
|
||||
{collection: "C", id: "X"}));
|
||||
test.isTrue(crossbar._matches({collection: "C", id: "X"},
|
||||
{collection: "C"}));
|
||||
|
||||
test.isFalse(DDPServer._InvalidationCrossbar._matches(
|
||||
{collection: "C", id: "X"}, {collection: "C", id: "Y"}));
|
||||
test.isFalse(crossbar._matches({collection: "C", id: "X"},
|
||||
{collection: "C", id: "Y"}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user