UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

37 lines (36 loc) 1.48 kB
import type { FanOut } from 'thingies/lib/fanout'; import type { JsonNode, JsonNodeView } from '../../nodes'; import type { SyncStore, SyncStoreUnsubscribe } from '../../../util/events/sync-store'; import type { NodeApi } from './nodes'; export declare class NodeEvents<N extends JsonNode = JsonNode> implements SyncStore<JsonNodeView<N>> { private readonly api; /** * Fired on any model change, even if the node's value has not changed. The * changes are fired once per microtask, so multiple changes in the same * microtask are batched into a single event. */ readonly onChanges: FanOut<JsonNodeView<N>>; /** * Similar to `.onChanges`, but fired when the node's view has changed, * checked using triple equality `===`. * * The strict equality identity is preserved deeply equal values, even for * objects and arrays. So, this event will not fire if there was a change * to the node's value, but the value is still deeply equal to the previous * value. * * This event depends on overall Model's `onChanges` event, which is * batched using `queueMicrotask`. */ readonly onViewChanges: FanOut<JsonNodeView<N>>; constructor(api: NodeApi<N>); /** * Called when this node is deleted. * * @internal * @ignore */ handleDelete(): void; readonly subscribe: (callback: () => void) => SyncStoreUnsubscribe; readonly getSnapshot: () => JsonNodeView<N>; }