wirejs-resources 0.1.61-realtime → 0.1.63-realtime

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,6 @@ export declare class RealtimeService<T = any> extends Resource {
15
15
  * The address the client will need to connect to.
16
16
  */
17
17
  get address(): string;
18
- publish(channel: string, data: T): Promise<void>;
18
+ publish(channel: string, data: T | T[]): Promise<void>;
19
19
  getStream(channel: string): Promise<MessageStream<T>>;
20
20
  }
@@ -117,7 +117,10 @@ export class RealtimeService extends Resource {
117
117
  console.log('Publishing to channel:', channel, data);
118
118
  (this.#channels.get(channel) || []).forEach((ws) => {
119
119
  if (ws.readyState === WebSocket.OPEN) {
120
- ws.send(JSON.stringify({ data }));
120
+ const events = Array.isArray(data) ? data : [data];
121
+ for (const event of events) {
122
+ ws.send(JSON.stringify({ data: event }));
123
+ }
121
124
  }
122
125
  });
123
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-resources",
3
- "version": "0.1.61-realtime",
3
+ "version": "0.1.63-realtime",
4
4
  "description": "Basic services and server-side resources for wirejs apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",