tasko/liveblocks.config.ts

74 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-03-15 21:03:28 +00:00
import { createClient } from '@liveblocks/client';
import { createRoomContext, createLiveblocksContext } from '@liveblocks/react';
2024-02-17 19:43:59 +00:00
const client = createClient({
publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY!,
throttle: 16,
2024-02-17 19:43:59 +00:00
});
type Presence = {
cursor: { x: number; y: number } | null;
2024-02-17 19:43:59 +00:00
};
type Storage = {};
2024-02-17 19:43:59 +00:00
type UserMeta = {};
2024-02-17 19:43:59 +00:00
type RoomEvent = {};
2024-02-17 19:43:59 +00:00
export type ThreadMetadata = {};
2024-02-17 19:43:59 +00:00
export const {
suspense: {
RoomProvider,
useRoom,
useMyPresence,
useUpdateMyPresence,
useSelf,
useOthers,
useOthersMapped,
useOthersListener,
2024-02-17 19:43:59 +00:00
useOthersConnectionIds,
useOther,
useBroadcastEvent,
useEventListener,
useErrorListener,
useStorage,
useBatch,
useHistory,
useUndo,
useRedo,
useCanUndo,
useCanRedo,
useMutation,
useStatus,
useLostConnectionListener,
useThreads,
useCreateThread,
useEditThreadMetadata,
useCreateComment,
useEditComment,
useDeleteComment,
useAddReaction,
useRemoveReaction,
useThreadSubscription,
useMarkThreadAsRead,
useRoomNotificationSettings,
useUpdateRoomNotificationSettings,
2024-03-15 21:03:28 +00:00
},
} = createRoomContext<Presence, Storage, UserMeta, RoomEvent, ThreadMetadata>(
client
);
2024-02-17 19:43:59 +00:00
export const {
suspense: {
LiveblocksProvider,
useMarkInboxNotificationAsRead,
useMarkAllInboxNotificationsAsRead,
useInboxNotifications,
useUnreadInboxNotificationsCount,
useUser,
useRoomInfo,
2024-03-15 21:03:28 +00:00
},
} = createLiveblocksContext<UserMeta, ThreadMetadata>(client);