Skip to content

Commit f569790

Browse files
committed
Merge pull request DefinitelyTyped#5906 from dumbmatter/master
Update pubsubjs to latest version
2 parents 273a567 + fc20784 commit f569790

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

pubsubjs/PubSub-tests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,16 @@ function test_Hierarchical_addressing() {
6868
// topics, three times in total
6969
// But, mySpecificSubscriber will only be called once, as it only
7070
// subscribes to the 'car.drive' topic
71+
}
72+
73+
function ClearAllSubscriptions() {
74+
// create a function to receive messages
75+
var mySubscriber = (msg: string, data: any) => { console.log(msg, data); }
76+
77+
// create two subscriptions
78+
PubSub.subscribe('topic1', mySubscriber);
79+
PubSub.subscribe('topic2', mySubscriber);
80+
81+
// unsubscribe from all subscrpitions
82+
PubSub.clearAllSubscriptions();
7183
}

pubsubjs/pubsub.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// Type definitions for PubSubJS 1.3.5
1+
// Type definitions for PubSubJS 1.5.2
22
// Project: https://github.com/mroderick/PubSubJS
33
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
44
// Definitions: https://github.com/borisyankov/DefinitelyTyped
55

66
declare module PubSubJS {
7-
interface Base extends Publish, Subscribe, Unsubscribe {
7+
interface Base extends Publish, Subscribe, Unsubscribe, ClearAllSubscriptions {
88
version: string;
99
name: string;
1010
}
@@ -25,6 +25,15 @@ declare module PubSubJS {
2525
interface Unsubscribe{
2626
unsubscribe(tokenOrFunction: any): any;
2727
}
28+
29+
30+
interface ClearAllSubscriptions{
31+
clearAllSubscriptions(): any;
32+
}
2833
}
2934

3035
declare var PubSub: PubSubJS.Base;
36+
37+
declare module "pubsub-js" {
38+
export = PubSub;
39+
}

0 commit comments

Comments
 (0)