@emeryld/rrroutes-client 2.6.3 → 2.6.4

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.
package/README.md CHANGED
@@ -347,8 +347,8 @@ const client = new SocketClient(events, {
347
347
  debug: { receive: true, emit: true, verbose: true, logger: console.log },
348
348
  })
349
349
 
350
- client.on('chat:message', (payload, { ctx }) => {
351
- console.log('socket message', payload.text, 'latency', ctx.latencyMs)
350
+ client.on('chat:message', (payload, meta) => {
351
+ console.log('socket message', payload.text, 'latency', meta?.ctx?.latencyMs)
352
352
  })
353
353
 
354
354
  void client.emit('chat:message', {
@@ -423,7 +423,7 @@ import { useSocketClient } from './socketProvider';
423
423
 
424
424
  const listRooms = client.build(registry.byKey['GET /v1/rooms'], { staleTime: 120_000 });
425
425
 
426
- const useSocketedRooms = buildSocketedRoute({
426
+ const socketedRooms = buildSocketedRoute({
427
427
  built: listRooms,
428
428
  toRooms: (page) => ({
429
429
  rooms: page.items.map((r) => r.id), // derive rooms from data (feeds supported)
@@ -432,8 +432,10 @@ const useSocketedRooms = buildSocketedRoute({
432
432
  }),
433
433
  useSocketClient,
434
434
  applySocket: {
435
- 'chat:message': (prev, payload) => {
436
- if (!prev) return prev;
435
+ 'chat:message': (prev, payload, meta) => {
436
+ if (!prev) return null; // explicit no-op update
437
+ const [args] = meta.args;
438
+ console.debug('socket patch args', args);
437
439
  // Example: bump unread count in cache
438
440
  const apply = (items: any[]) =>
439
441
  items.map((room) =>
@@ -447,7 +449,7 @@ const useSocketedRooms = buildSocketedRoute({
447
449
  });
448
450
 
449
451
  function RoomList() {
450
- const { data, rooms } = useSocketedRooms();
452
+ const { data, rooms } = socketedRooms.useEndpoint();
451
453
  return (
452
454
  <>
453
455
  <p>Subscribed rooms: {rooms.join(', ')}</p>
@@ -457,6 +459,8 @@ function RoomList() {
457
459
  }
458
460
  ```
459
461
 
462
+ `buildSocketedRoute(...)` returns a built endpoint object with `useEndpoint()` plus the original built helpers. `applySocket` receives `{ envelope?, ctx?, args }` and can return `null` to skip cache updates.
463
+
460
464
  ---
461
465
 
462
466
  ## Edge cases & notes