import { Schema } from "effect";
const CursorSchema = Schema.Struct({ x: Schema.Number, y: Schema.Number });
const cursors = client.awareness("cursors", CursorSchema);
// Send our state (fire-and-forget — not queued when offline)
cursors.update({ x: 120, y: 80 });
// Listen to peer updates
const unsub = cursors.onChange(peers => {
for (const entry of peers) {
// entry.clientId: number
// entry.data: { x: number; y: number }
// entry.receivedAt: number (local timestamp)
renderCursor(entry.clientId, entry.data.x, entry.data.y);
}
});
// Clear our entry (e.g. on mouse leave, tab hidden, component unmount)
cursors.clear();
unsub();