mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 03:48:39 +00:00
26 lines
740 B
TypeScript
26 lines
740 B
TypeScript
import type { MainEventRegister, WorkspaceMeta } from '../type';
|
|
import { deleteWorkspace, getWorkspaceMeta, listWorkspaces } from './handlers';
|
|
import { workspaceSubjects } from './subjects';
|
|
|
|
export * from './handlers';
|
|
export * from './subjects';
|
|
|
|
export const workspaceEvents = {
|
|
onMetaChange: (
|
|
fn: (meta: { workspaceId: string; meta: WorkspaceMeta }) => void
|
|
) => {
|
|
const sub = workspaceSubjects.meta.subscribe(fn);
|
|
return () => {
|
|
sub.unsubscribe();
|
|
};
|
|
},
|
|
} satisfies Record<string, MainEventRegister>;
|
|
|
|
export const workspaceHandlers = {
|
|
list: async () => listWorkspaces(),
|
|
delete: async (id: string) => deleteWorkspace(id),
|
|
getMeta: async (id: string) => {
|
|
return getWorkspaceMeta(id);
|
|
},
|
|
};
|