4 ms·
> presence Congrats on the launch! You have a pointer to docs about presence? Use-case is an ephemeral chatroom where I want to show who's online.
by rgbrgb 4y ago
> presence
Congrats on the launch! You have a pointer to docs about presence? Use-case is an ephemeral chatroom where I want to show who's online.
- paulgb 4y agoGood catch, this should be in the react docs but it's missing. Until then, it's pretty simple. You call `const presence = usePresence({})` and pass in any data you want, and the `presence` value that gets returned is an object that maps client IDs (a unique string for each client) to the values that they passed in to `usePresence`. Here's an example from the voxel demo: https://github.com/drifting-in-space/driftdb/blob/af64f62b29a0baae09a7d450affa9e69ba61b000/js-pkg/demos/src/pages/voxel.tsx#L94 https://github.com/drifting-in-space/driftdb/blob/af64f62b29... And from the canvas demo: https://github.com/drifting-in-space/driftdb/blob/af64f62b29a0baae09a7d450affa9e69ba61b000/js-pkg/demos/src/pages/shared-canvas.tsx#L44 https://github.com/drifting-in-space/driftdb/blob/af64f62b29...