UNPKG

mobx-keystone-yjs

Version:

Yjs bindings for mobx-keystone

33 lines (32 loc) 914 B
import { AnyDataModel, AnyModel, AnyStandardType, ModelClass, TypeToData } from 'mobx-keystone'; import * as Y from "yjs"; /** * Creates a bidirectional binding between a Y.js data structure and a mobx-keystone model. */ export declare function bindYjsToMobxKeystone<TType extends AnyStandardType | ModelClass<AnyModel> | ModelClass<AnyDataModel>>({ yjsDoc, yjsObject, mobxKeystoneType, }: { /** * The Y.js document. */ yjsDoc: Y.Doc; /** * The bound Y.js data structure. */ yjsObject: Y.Map<any> | Y.Array<any> | Y.Text; /** * The mobx-keystone model type. */ mobxKeystoneType: TType; }): { /** * The bound mobx-keystone instance. */ boundObject: TypeToData<TType>; /** * Disposes the binding. */ dispose: () => void; /** * The Y.js origin symbol used for binding transactions. */ yjsOrigin: symbol; };