3 ms·
Can this be used in the Dart/Flutter world?
by atentaten 4y ago
Can this be used in the Dart/Flutter world?
- paulgb 4y agoThe server itself speaks a very simple WebSocket protocol[1], so it could be used by anything that can speak WebSocket. The JS/React bindings that implement the actual data sync patterns (shared state, shared reducers, presence) haven’t been ported to Dart (yet?) though. [1] https://driftdb.com/docs/api https://driftdb.com/docs/api
- 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...