(event: K, payload: z.TypeOf<O[K]>)
| 107 | } |
| 108 | |
| 109 | push<K extends keyof O & string>(event: K, payload: z.TypeOf<O[K]>): void { |
| 110 | // Queue outgoing events until we are subscribed. |
| 111 | if (!this.subscribed) { |
| 112 | this.queue.push({ event, payload }); |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | const schema = this.events.outgoing[event]; |
| 117 | |
| 118 | if (schema === undefined) { |
| 119 | throw new Error(`Cannot push unknown event '${event}' for topic '${this.topic}'`); |
| 120 | } |
| 121 | |
| 122 | this.client.push(this.topic, event, schema.parse(payload)); |
| 123 | } |
| 124 | |
| 125 | private receiveSubscribedEvent(payload: { id: string }) { |
| 126 | // This shouldn't normally happen, but could if multiple channels for the |
no outgoing calls
no test coverage detected