Skip to content

Commit a677390

Browse files
committed
feat: remove channel send method
1 parent c5af782 commit a677390

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

packages/core/realtime-js/src/RealtimeChannel.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class RealtimeChannel {
1616

1717
constructor(
1818
public topic: string,
19-
public params: { [key: string]: unknown } = {},
19+
public params: { [key: string]: any } = {},
2020
public socket: RealtimeClient
2121
) {
2222
this.timeout = this.socket.timeout
@@ -163,7 +163,7 @@ export default class RealtimeChannel {
163163
return this.socket.isConnected() && this.isJoined()
164164
}
165165

166-
push(event: CHANNEL_EVENTS, payload: any, timeout = this.timeout) {
166+
push(event: string, payload: { [key: string]: any }, timeout = this.timeout) {
167167
if (!this.joinedOnce) {
168168
throw `tried to push '${event}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`
169169
}
@@ -178,7 +178,7 @@ export default class RealtimeChannel {
178178
return pushEvent
179179
}
180180

181-
updateJoinPayload(payload: { [key: string]: unknown }): void {
181+
updateJoinPayload(payload: { [key: string]: any }): void {
182182
this.joinPush.updatePayload(payload)
183183
}
184184

@@ -259,23 +259,6 @@ export default class RealtimeChannel {
259259
.map((bind) => bind.callback(handledPayload, ref))
260260
}
261261

262-
send(
263-
payload: { type: string; [key: string]: any },
264-
opts: { [key: string]: any } = {}
265-
): Promise<'ok' | 'timeout'> {
266-
const push = this.push(
267-
payload.type as any,
268-
payload,
269-
opts.timeout ?? this.timeout
270-
)
271-
272-
return new Promise((resolve) => {
273-
push
274-
.receive('ok', () => resolve('ok'))
275-
.receive('timeout', () => resolve('timeout'))
276-
})
277-
}
278-
279262
replyEventName(ref: string): string {
280263
return `chan_reply_${ref}`
281264
}

packages/core/realtime-js/src/RealtimePresence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export default class RealtimePresence {
300300
}, {} as PresenceState)
301301
}
302302

303-
private static cloneDeep(obj: object) {
303+
private static cloneDeep(obj: { [key: string]: any }) {
304304
return JSON.parse(JSON.stringify(obj))
305305
}
306306

packages/core/realtime-js/src/lib/push.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class Push {
2626
constructor(
2727
public channel: RealtimeChannel,
2828
public event: string,
29-
public payload: { [key: string]: unknown } = {},
29+
public payload: { [key: string]: any } = {},
3030
public timeout: number = DEFAULT_TIMEOUT
3131
) {}
3232

@@ -54,7 +54,7 @@ export default class Push {
5454
})
5555
}
5656

57-
updatePayload(payload: { [key: string]: unknown }): void {
57+
updatePayload(payload: { [key: string]: any }): void {
5858
this.payload = { ...this.payload, ...payload }
5959
}
6060

packages/core/realtime-js/src/lib/serializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class Serializer {
3131
ref: null
3232
topic: string
3333
event: string
34-
payload: object
34+
payload: { [key: string]: any }
3535
} {
3636
const topicSize = view.getUint8(1)
3737
const eventSize = view.getUint8(2)

0 commit comments

Comments
 (0)