@liveblocks/node
Advanced tools
Changelog
v0.17.9
Changelog
v0.17.8
In @liveblocks/client:
canUndo()
and canRedo()
utilities to room.history
"history"
event type to room.subscribe()
to subscribe to the current
user's history changesIn @liveblocks/react:
useCanUndo()
and useCanRedo()
hooksChangelog
v0.17.7
In @liveblocks/zustand:
TPresence
,
TStorage
, TUserMeta
, and TRoomEvent
are now optional.Note that @liveblocks/zustand
does not work with zustand > v4 because v3 and
v4 have completely different type definitions. As soon as zustand v4 is out of
the RC phase, we will consider updating our middleware to work with the latest
version.
Let's take a look at our To-do list example. Without our middleware, the store would look like this:
import create from "zustand";
type State = {
draft: string;
isTyping: boolean;
todos: Todo[];
setDraft: (draft: string) => void;
addTodo: () => void;
deleteTodo: (index: number) => void;
};
create<State>(/* ... */);
With our middleware, you simply need to move the State
param at the middleware
level:
import create from "zustand";
import { createClient } from "@liveblocks/client";
import { middleware } from "@liveblocks/zustand";
const client = createClient({ /*...*/ });
type State = {
draft: string;
isTyping: boolean;
todos: Todo[];
setDraft: (draft: string) => void;
addTodo: () => void;
deleteTodo: (index: number) => void;
};
create(
middleware<State>(/* ... */, {
client,
presenceMapping: { isTyping: true },
storageMapping: { todos: true }
})
);
If you want to type others
presence, you can use the TPresence
generic
argument on the middleware.
type Presence = {
isTyping: true;
}
const useStore = create(
middleware<State, Presence>(/* ... */, {
client,
presenceMapping: { isTyping: true },
storageMapping: { todos: true }
})
);
// In your component
useStore(state => state.liveblocks.others[0].presence?.isTyping)
Changelog
v0.17.6
In @liveblocks/react:
RoomContext
in the return value of createRoomContext()
Changelog
v0.17.5
In @liveblocks/react:
key
argument of useMap()
, useList()
,
useObject()
did not resubscribe to updates correctlyRoomProvider
's initial presence/storage props on
subsequent renders. This makes it behave closer to useState(initialState)