UNPKG

simpleddp-node

Version:

The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments

40 lines (39 loc) 1.14 kB
import { ddpReactiveCollection } from './ddpReactiveCollection'; /** * A reducer class for a reactive document. * @constructor */ export declare class ddpReducer<RArgs extends [any[], any, number, any[]], RResult, RInit, TCol> { private _ddpReactiveCollectionInstance; private readonly _reducer; private _started; private readonly _data; private _tickers; private readonly _initialValue; constructor(ddpReactiveCollectionInstance: ddpReactiveCollection<TCol>, reducer: (...args: RArgs) => RResult, initialValue: RInit); /** * Forcibly reduces reactive data. */ doReduce(): void; /** * Starts reactiveness for the reduced value of the collection. * This method is being called on instance creation. */ start(): void; /** * Stops reactiveness. */ stop(): void; /** * Returns reactive reduce. */ data(): Record<string, any>; /** * Runs a function every time a change occurs. * @param {Function} f - Function which recieves a reduced value at each change. */ onChange(f: {}): { start: () => void; stop: () => void; }; }