UNPKG

lib0

Version:

isomorphic utility functions

57 lines • 2.33 kB
export function deltaRDT<Conf extends delta.DeltaConf>($delta: Schema<delta.Delta<Conf>>): DeltaRDT<Conf>; export type Schema<T> = import("../../schema.js").Schema<T>; export type RDT<Conf extends delta.DeltaConf> = import("../rdt.js").RDT<Conf>; import * as delta from '../delta.js'; /** * @template T * @typedef {import('../../schema.js').Schema<T>} Schema */ /** * @template {delta.DeltaConf} Conf * @typedef {import('../rdt.js').RDT<Conf>} RDT */ /** * An in-memory RDT whose state is the accumulated delta. Calling `applyDelta` merges the incoming delta * into `state` (via {@link delta.DeltaBuilder#apply}) and re-emits it as a `'delta'`. * * @template {delta.DeltaConf} Conf * @implements {RDT<Conf>} * @extends {ObservableV2<{ delta: (delta: delta.Delta<Conf>, origin: any) => void, destroy: (rdt: DeltaRDT<Conf>) => void }>} */ declare class DeltaRDT<Conf extends delta.DeltaConf> extends ObservableV2<{ delta: (delta: delta.Delta<Conf>, origin: any) => void; destroy: (rdt: DeltaRDT<Conf>) => void; }> implements RDT<Conf> { /** * @param {Schema<delta.Delta<Conf>>} $delta schema of the deltas this RDT produces */ constructor($delta: Schema<delta.Delta<Conf>>); $delta: import("../../schema.js").Schema<delta.Delta<Conf>>; /** * @type {delta.DeltaBuilderAny?} */ state: delta.DeltaBuilderAny | null; _mux: mux.mutex; /** * Merge an incoming delta into the current state and notify observers. Always returns `null`: this * RDT accepts every valid delta unchanged, so it never produces a fix. * * @param {delta.Delta<Conf>} d * @param {any} [origin] who produced the change; forwarded verbatim on the emitted `'delta'` event so * listeners can recognise (and skip) changes they made themselves — see {@link RDT} “Origins”. Defaults * to `null` (an anonymous/local change). * @return {null} */ applyDelta(d: delta.Delta<Conf>, origin?: any): null; /** * The current state as a delta: the accumulated `state`, or an empty delta when nothing has been * applied yet. * * @return {delta.Delta<Conf>} */ get delta(): delta.Delta<Conf>; } import { ObservableV2 } from '../../observable.js'; import * as mux from '../../mutex.js'; export {}; //# sourceMappingURL=delta.d.ts.map