Skip to content

Commit 26fbcf3

Browse files
committed
Implement error handling
1 parent 248d6ff commit 26fbcf3

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

src/channel/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export abstract class Channel {
3232
abstract stopListening(event: string): Channel;
3333

3434
/**
35-
* Stop listening for a whispser event on the channel instance.
35+
* Stop listening for a whisper event on the channel instance.
3636
*/
3737
stopListeningForWhisper(event: string): Channel {
3838
return this.stopListening('.client-' + event);

src/channel/null-presence-channel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export class NullPresenceChannel extends NullChannel implements PresenceChannel
1212
return this;
1313
}
1414

15+
/**
16+
* Register a callback to be called anytime an error occurs.
17+
*/
18+
error(callback: Function): NullPresenceChannel {
19+
return this;
20+
}
21+
1522
/**
1623
* Listen for someone joining the channel.
1724
*/

src/channel/presence-channel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export interface PresenceChannel {
77
*/
88
here(callback: Function): PresenceChannel;
99

10+
/**
11+
* Register a callback to be called anytime an error occurs.
12+
*/
13+
error(callback: Function): PresenceChannel;
14+
1015
/**
1116
* Listen for someone joining the channel.
1217
*/

src/channel/pusher-channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventFormatter } from './../util';
1+
import { EventFormatter } from '../util';
22
import { Channel } from './channel';
33

44
/**

src/channel/pusher-presence-channel.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ export class PusherPresenceChannel extends PusherChannel implements PresenceChan
1616
return this;
1717
}
1818

19+
/**
20+
* Register a callback to be called anytime a subscription error occurs.
21+
*/
22+
error(callback: Function): PusherPresenceChannel {
23+
this.on('pusher:subscription_error', (status) => {
24+
callback(status);
25+
});
26+
27+
return this;
28+
}
29+
1930
/**
2031
* Listen for someone joining the channel.
2132
*/

src/channel/socketio-channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventFormatter } from './../util';
1+
import { EventFormatter } from '../util';
22
import { Channel } from './channel';
33

44
/**

src/channel/socketio-presence-channel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export class SocketIoPresenceChannel extends SocketIoPrivateChannel implements P
1616
return this;
1717
}
1818

19+
/**
20+
* Register a callback to be called anytime an error occurs.
21+
*/
22+
error(callback: Function): SocketIoPresenceChannel {
23+
return this;
24+
}
25+
1926
/**
2027
* Listen for someone joining the channel.
2128
*/

0 commit comments

Comments
 (0)