diff --git a/src/backend.ts b/src/backend.ts index d126cba..ffbb8fa 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -1,6 +1,27 @@ import EventEmitter from 'events'; import { Chat } from './types'; +/* + +Sync and login requires a backend implementation. + +Example syncing: + +const customBackend = new MyCustomBackend(); +customBackend.register(); + +In your custom backend, load saved chats from the server and call chatManager.loadChat(chat); + +chatManager.on('messages', async (messages: Message[]) => { + // send messages to server +}); + +chatManager.on('title', async (id: string, title: string) => { + // send updated chat title to server +}); + +*/ + export let backend: Backend | null = null; export class Backend extends EventEmitter { @@ -13,21 +34,21 @@ export class Backend extends EventEmitter { } get isAuthenticated() { + // return whether the user is currently signed in return false; } async signIn(options?: any) { + // sign in the user } async shareChat(chat: Chat): Promise { + // create a public share from the chat, and return the share's ID return null; } async getSharedChat(id: string): Promise { + // load a publicly shared chat from its ID return null; } -} - -export function getBackend() { - return backend; } \ No newline at end of file