From 532315aff7d814df757502c84a508830af185a38 Mon Sep 17 00:00:00 2001 From: Blake Fischer Date: Fri, 5 Aug 2022 07:29:20 -0400 Subject: [PATCH 1/2] Allow events triggered on channel instance to not specify channelName --- src/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 51bd71c..b47925f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -83,11 +83,12 @@ export class PusherChannel { }); } - async trigger(event: PusherEvent) { - if (event.channelName !== this.channelName) { + async trigger(event: Omit & Partial>) { + const channelName = event.channelName ?? this.channelName + if (channelName !== this.channelName) { throw 'Event is not for this channel'; } - return Pusher.getInstance().trigger(event); + return Pusher.getInstance().trigger({ ...event, channelName }); } } From 55595a7fbb353ae28be19f2a5cf5c6d06ad56769 Mon Sep 17 00:00:00 2001 From: Blake Fischer Date: Fri, 5 Aug 2022 07:37:12 -0400 Subject: [PATCH 2/2] Fix formatting --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index b47925f..048b29f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -84,7 +84,7 @@ export class PusherChannel { } async trigger(event: Omit & Partial>) { - const channelName = event.channelName ?? this.channelName + const channelName = event.channelName ?? this.channelName; if (channelName !== this.channelName) { throw 'Event is not for this channel'; }