Skip to content

Commit

Permalink
Merge pull request #75 from rubennorte/bugfix/immediate-exceptions-no…
Browse files Browse the repository at this point in the history
…t-working-with-namespaces

Bugfix/immediate exceptions not working with namespaces
  • Loading branch information
mroderick committed Mar 2, 2015
2 parents 18b38e2 + 138d879 commit c3a9d11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ https://github.com/mroderick/PubSubJS
while( position !== -1 ){
topic = topic.substr( 0, position );
position = topic.lastIndexOf('.');
deliverMessage( message, topic, data );
deliverMessage( message, topic, data, immediateExceptions );
}
};
}
Expand Down
21 changes: 21 additions & 0 deletions test/test-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,27 @@
delete PubSub.immediateExceptions;
},

"publish method should fail immediately on exceptions in namespaces when immediateExceptions is true" : function(){
var func1 = function(){
throw('some error');
},
spy1 = this.spy();

PubSub.subscribe( 'buy', func1 );
PubSub.subscribe( 'buy', spy1 );

PubSub.immediateExceptions = true;

assert.exception( function(){
PubSub.publishSync( 'buy.tomatoes', 'some data' );
});

refute( spy1.called );

// make sure we restore PubSub to it's original state
delete PubSub.immediateExceptions;
},

"publish should call all subscribers, even when there are unsubscriptions within" : function(done){
var topic = TestHelper.getUniqueString(),
spy1 = this.spy(),
Expand Down

0 comments on commit c3a9d11

Please sign in to comment.