test-rxdb
Version:
A local realtime NoSQL Database for JavaScript applications -
49 lines (48 loc) • 1.92 kB
TypeScript
import type { RxChangeEvent, RxCollection } from './types/index.d.ts';
/**
* This buffer rembemers previous change events
* so that queries can use them on .exec()
* to calculate the new result set via event-reduce instead
* of running the query against the storage.
*/
export declare class ChangeEventBuffer<RxDocType> {
collection: RxCollection;
/**
* These properties are private to ensure they cannot
* be read without first processing the lazy tasks.
*/
private subs;
private counter;
private eventCounterMap;
/**
* array with changeEvents
* starts with oldest known event, ends with newest
*/
private buffer;
limit: number;
private tasks;
constructor(collection: RxCollection);
private processTasks;
private _handleChangeEvents;
getCounter(): number;
getBuffer(): RxChangeEvent<RxDocType>[];
/**
* gets the array-index for the given pointer
* @return arrayIndex which can be used to iterate from there. If null, pointer is out of lower bound
*/
getArrayIndexByPointer(pointer: number): number | null;
/**
* get all changeEvents which came in later than the pointer-event
* @return array with change-events. If null, pointer out of bounds
*/
getFrom(pointer: number): RxChangeEvent<RxDocType>[] | null;
runFrom(pointer: number, fn: Function): void;
/**
* no matter how many operations are done on one document,
* only the last operation has to be checked to calculate the new state
* this function reduces the events to the last ChangeEvent of each doc
*/
reduceByLastOfDoc(changeEvents: RxChangeEvent<RxDocType>[]): RxChangeEvent<RxDocType>[];
destroy(): void;
}
export declare function createChangeEventBuffer<RxdocType>(collection: RxCollection<RxdocType, any>): ChangeEventBuffer<RxdocType>;