mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 15:46:29 +08:00
34703a3b7d
https://github.com/toeverything/AFFiNE/blob/eyhn/feat/new-sync/packages/common/infra/src/workspace/engine/doc/README.md
39 lines
800 B
TypeScript
39 lines
800 B
TypeScript
import {
|
|
type GlobalState,
|
|
type Memento,
|
|
type Workspace,
|
|
type WorkspaceLocalState,
|
|
wrapMemento,
|
|
} from '@toeverything/infra';
|
|
|
|
export class WorkspaceLocalStateImpl implements WorkspaceLocalState {
|
|
wrapped: Memento;
|
|
constructor(workspace: Workspace, globalState: GlobalState) {
|
|
this.wrapped = wrapMemento(globalState, `workspace-state:${workspace.id}:`);
|
|
}
|
|
|
|
keys(): string[] {
|
|
return this.wrapped.keys();
|
|
}
|
|
|
|
get<T>(key: string): T | null {
|
|
return this.wrapped.get<T>(key);
|
|
}
|
|
|
|
watch<T>(key: string) {
|
|
return this.wrapped.watch<T>(key);
|
|
}
|
|
|
|
set<T>(key: string, value: T | null): void {
|
|
return this.wrapped.set<T>(key, value);
|
|
}
|
|
|
|
del(key: string): void {
|
|
return this.wrapped.del(key);
|
|
}
|
|
|
|
clear(): void {
|
|
return this.wrapped.clear();
|
|
}
|
|
}
|