mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-03-16 22:20:23 +00:00
Updated publish loop to eliminate need for clone
This commit is contained in:
parent
b0461a54b4
commit
180593a88b
4 changed files with 32 additions and 26 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"anvil.uglify" : {},
|
||||
"anvil.uglify" : { "all" :true },
|
||||
"anvil.http": {
|
||||
"paths": {
|
||||
"/": "./"
|
||||
|
|
|
|||
|
|
@ -247,19 +247,22 @@
|
|||
tap( envelope.data, envelope );
|
||||
} );
|
||||
if ( this.subscriptions[envelope.channel] ) {
|
||||
_.each( this.subscriptions[envelope.channel], function ( topic ) {
|
||||
_.each( this.subscriptions[envelope.channel], function ( subscribers ) {
|
||||
// TODO: research faster ways to handle this than _.clone
|
||||
_.each( _.clone( topic ), function ( subDef ) {
|
||||
if ( postal.configuration.resolver.compare( subDef.topic, envelope.topic ) ) {
|
||||
if ( _.all( subDef.constraints, function ( constraint ) {
|
||||
return constraint.call( subDef.context, envelope.data, envelope );
|
||||
} ) ) {
|
||||
if ( typeof subDef.callback === 'function' ) {
|
||||
subDef.callback.call( subDef.context, envelope.data, envelope );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
var idx = 0;
|
||||
while(idx < subscribers.length) {
|
||||
(function(subDef){
|
||||
if ( postal.configuration.resolver.compare( subDef.topic, envelope.topic ) ) {
|
||||
if ( _.all( subDef.constraints, function ( constraint ) {
|
||||
return constraint.call( subDef.context, envelope.data, envelope );
|
||||
} ) ) {
|
||||
if ( typeof subDef.callback === 'function' ) {
|
||||
subDef.callback.call( subDef.context, envelope.data, envelope );
|
||||
}
|
||||
}
|
||||
}
|
||||
}(subscribers[idx++]));
|
||||
}
|
||||
} );
|
||||
}
|
||||
return envelope;
|
||||
|
|
|
|||
2
lib/postal.min.js
vendored
2
lib/postal.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -16,19 +16,22 @@ var localBus = {
|
|||
tap( envelope.data, envelope );
|
||||
} );
|
||||
if ( this.subscriptions[envelope.channel] ) {
|
||||
_.each( this.subscriptions[envelope.channel], function ( topic ) {
|
||||
_.each( this.subscriptions[envelope.channel], function ( subscribers ) {
|
||||
// TODO: research faster ways to handle this than _.clone
|
||||
_.each( _.clone( topic ), function ( subDef ) {
|
||||
if ( postal.configuration.resolver.compare( subDef.topic, envelope.topic ) ) {
|
||||
if ( _.all( subDef.constraints, function ( constraint ) {
|
||||
return constraint.call( subDef.context, envelope.data, envelope );
|
||||
} ) ) {
|
||||
if ( typeof subDef.callback === 'function' ) {
|
||||
subDef.callback.call( subDef.context, envelope.data, envelope );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
var idx = 0;
|
||||
while(idx < subscribers.length) {
|
||||
(function(subDef){
|
||||
if ( postal.configuration.resolver.compare( subDef.topic, envelope.topic ) ) {
|
||||
if ( _.all( subDef.constraints, function ( constraint ) {
|
||||
return constraint.call( subDef.context, envelope.data, envelope );
|
||||
} ) ) {
|
||||
if ( typeof subDef.callback === 'function' ) {
|
||||
subDef.callback.call( subDef.context, envelope.data, envelope );
|
||||
}
|
||||
}
|
||||
}
|
||||
}(subscribers[idx++]));
|
||||
}
|
||||
} );
|
||||
}
|
||||
return envelope;
|
||||
|
|
|
|||
Loading…
Reference in a new issue