0.0.12 • Published 3 years ago
@strict-yjs/jotai v0.0.12
Strict YJS - Jotai
Strongly typed YJS using runtime codecs with io-ts. And Jotai for read-write and change tracking.
Rough idea
import * as YjsJotai from "@strict-yjs/jotai";
import { assert, t } from "./utils";
import * as Y from "yjs";
import { Store } from "./Store";
const codec = YjsJotai.doc({
foo: YjsJotai.array(t.DateFromISOString),
bar: YjsJotai.type(
t.type({
a: t.string,
})
),
});
const yDoc = new Y.Doc();
const docAtom = t.decodeOrThrow(codec)(yDoc);
const nowDate = new Date();
Store.closure((store) => {
const doc = store.get(docAtom);
assert.invariant(doc?.foo !== undefined, "");
store.sub(doc.foo);
store.set(doc.foo, (_current, op) => op.push(nowDate));
const foo = store.get(doc.foo);
expect(foo).toEqual([nowDate]);
expect(yDoc.getArray("foo").toArray()).toEqual([nowDate.toISOString()]);
});
0.0.10
3 years ago
0.0.11
3 years ago
0.0.12
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.3-alpha.5
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3-alpha.4
3 years ago
0.0.3-alpha.3
3 years ago
0.0.3-alpha.2
3 years ago
0.0.3-alpha.1
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago