0.1.5 • Published 1 year ago
@netless/y v0.1.5
@netless/y
Glue between netless app and CRDT libraries
import { createVector } from "@netless/y";
// var App = { kind, setup(context) {
const vector = createVector(context, "namespace");
vector.forEach((update) => CRDT.applyUpdate(update));
CRDT.on("update", (update) => vector.push(update));
vector.on("update", (update) => CRDT.applyUpdate(update));
See src/yjs.ts for a more real-life use case.
Structure
Vector
Think of it as a growing array, you can push CRDT operations into it.
type Value = any; // any JSON-serializable value
class Vector {
readonly size: number;
forEach(callback: (update: Value, index: number) => void): void;
push(update: Value): void;
swap(updates: Value[]): void;
on(event: "update", callback: (update: Value) => void): void;
}
License
MIT @ netless
0.2.0-canary.1
1 year ago
0.2.0-canary.0
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago