UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

46 lines (45 loc) 1.47 kB
import { FanOut, type FanOutUnsubscribe, type FanOutListener } from 'thingies/lib/fanout'; /** * Merges multiple fanouts into a single fanout. The merged fanout emits the * same data as the source fanouts. */ export declare class MergeFanOut<D> extends FanOut<D> { private readonly fanouts; private unsubs; constructor(fanouts: FanOut<any>[]); listen(listener: FanOutListener<D>): FanOutUnsubscribe; } /** * Buffers data from a fanout and emits the buffered data once per microtask. */ export declare class MicrotaskBufferFanOut<I> extends FanOut<I[]> { private readonly source; private buffer; private unsub?; constructor(source: FanOut<I>); listen(listener: FanOutListener<I[]>): FanOutUnsubscribe; clear(): void; } /** * Maps the data from a fanout using a mapper function. */ export declare class MapFanOut<I, O> extends FanOut<O> { private readonly source; private readonly mapper; constructor(source: FanOut<I>, mapper: (data: I) => O); private unsub?; listen(listener: FanOutListener<O>): FanOutUnsubscribe; clear(): void; } /** * Emits only when the source fanout emits a new value. The first value is * emitted immediately. */ export declare class OnNewFanOut<D> extends FanOut<D> { private readonly source; private last; private unsub?; constructor(source: FanOut<D>, last?: D | undefined); listen(listener: FanOutListener<D>): FanOutUnsubscribe; clear(): void; }