File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
packages/core/realtime-js/src Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,29 @@ export default class RealtimeChannel {
80
80
if ( this . joinedOnce ) {
81
81
throw `tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance`
82
82
} else {
83
+ const configs = this . bindings . reduce (
84
+ ( acc , binding : { [ key : string ] : any } ) => {
85
+ const { type } = binding
86
+ if (
87
+ ! [
88
+ 'phx_close' ,
89
+ 'phx_error' ,
90
+ 'phx_reply' ,
91
+ 'presence_diff' ,
92
+ 'presence_state' ,
93
+ ] . includes ( type )
94
+ ) {
95
+ acc [ type ] = binding
96
+ }
97
+ return acc
98
+ } ,
99
+ { }
100
+ )
101
+
102
+ if ( Object . keys ( configs ) . length ) {
103
+ this . updateJoinPayload ( { configs } )
104
+ }
105
+
83
106
this . joinedOnce = true
84
107
this . rejoin ( timeout )
85
108
return this . joinPush
@@ -211,9 +234,9 @@ export default class RealtimeChannel {
211
234
send ( payload : { type : string ; [ key : string ] : any } ) {
212
235
const push = this . push ( payload . type as any , payload )
213
236
214
- return new Promise ( ( resolve ) => {
237
+ return new Promise ( ( resolve , reject ) => {
215
238
push . receive ( 'ok' , ( ) => resolve ( 'ok' ) )
216
- push . receive ( 'timeout' , ( ) => resolve ( 'timeout' ) )
239
+ push . receive ( 'timeout' , ( ) => reject ( 'timeout' ) )
217
240
} )
218
241
}
219
242
You can’t perform that action at this time.
0 commit comments