-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathliveblocks.config.ts
49 lines (43 loc) · 1.53 KB
/
liveblocks.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { createClient } from '@liveblocks/client'
import { createRoomContext } from '@liveblocks/react'
const client = createClient({
authEndpoint: '/api/auth'
})
// Presence represents the properties that will exist on every User in the Room
// and that will automatically be kept in sync. Accessible through the
// `user.presence` property. Must be JSON-serializable.
type Presence = {
instrument: string
notes: number[]
}
// Optionally, Storage represents the shared document that persists in the
// Room, even after all Users leave. Fields under Storage typically are
// LiveList, LiveMap, LiveObject instances, for which updates are
// automatically persisted and synced to all connected clients.
type Storage = {
// author: LiveObject<{ firstName: string, lastName: string }>,
// ...
}
// Optionally, UserMeta represents static/readonly metadata on each User, as
// provided by your own custom auth backend (if used). Useful for data that
// will not change during a session, like a User's name or avatar.
type UserMeta = {
id?: string, // Accessible through `user.id`
info: {
name: string,
color: string,
picture: string
} // Accessible through `user.info`
}
// Optionally, the type of custom events broadcasted and listened for in this
// room. Must be JSON-serializable.
// type RoomEvent = {};
export const {
suspense: {
RoomProvider,
useUpdateMyPresence,
useOthers,
useSelf
}
/* ...all the other hooks you’re using... */
} = createRoomContext<Presence, Storage, UserMeta/*, RoomEvent */>(client)