diff --git a/pubsubjs/PubSub-tests.ts b/pubsubjs/PubSub-tests.ts index 6f0163e97..0a452d08e 100644 --- a/pubsubjs/PubSub-tests.ts +++ b/pubsubjs/PubSub-tests.ts @@ -68,4 +68,16 @@ function test_Hierarchical_addressing() { // topics, three times in total // But, mySpecificSubscriber will only be called once, as it only // subscribes to the 'car.drive' topic +} + +function ClearAllSubscriptions() { + // create a function to receive messages + var mySubscriber = (msg: string, data: any) => { console.log(msg, data); } + + // create two subscriptions + PubSub.subscribe('topic1', mySubscriber); + PubSub.subscribe('topic2', mySubscriber); + + // unsubscribe from all subscrpitions + PubSub.clearAllSubscriptions(); } \ No newline at end of file diff --git a/pubsubjs/pubsub.d.ts b/pubsubjs/pubsub.d.ts index e24c901a4..d8e6e077d 100644 --- a/pubsubjs/pubsub.d.ts +++ b/pubsubjs/pubsub.d.ts @@ -1,10 +1,10 @@ -// Type definitions for PubSubJS 1.3.5 +// Type definitions for PubSubJS 1.5.2 // Project: https://github.com/mroderick/PubSubJS // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module PubSubJS { - interface Base extends Publish, Subscribe, Unsubscribe { + interface Base extends Publish, Subscribe, Unsubscribe, ClearAllSubscriptions { version: string; name: string; } @@ -25,6 +25,15 @@ declare module PubSubJS { interface Unsubscribe{ unsubscribe(tokenOrFunction: any): any; } + + + interface ClearAllSubscriptions{ + clearAllSubscriptions(): any; + } } declare var PubSub: PubSubJS.Base; + +declare module "pubsub-js" { + export = PubSub; +}