CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/app-framework/syncdb/index.ts
Views: 687
1
/*
2
Hooks and Context for working with a SyncDB object with react.
3
4
This is fairly self contained.
5
6
<SyncdbContext syncdb={...}>
7
react tree that uses the other hooks
8
</<SyncdbContext>
9
10
11
- useSyncdbContext: easy access to the syncdb
12
const { syncdb } = useSyncdbContext();
13
14
- useSyncdbRecord: access to a particular object in the syncdb defined by
15
a primary key. You can get and set it like using setValue with immediate
16
updates; it gets commited to the sync database with debouncing and remote
17
changes update it.
18
19
[record, setRecord] = useSyncdbRecord<TypeOfRecord>({key:..., defaultValue:..., debounceMs:...})
20
21
*/
22
23
import useSyncdbRecord from "./use-syncdb-record";
24
export { useSyncdbRecord };
25
26
export { useSyncdbContext, SyncdbContext } from "./syncdb-context";
27
28