/** * This plugin contains the primitives to create * a NxDB client-server replication. * It is used in the other replication plugins * but also can be used as standalone with a custom replication handler. */ import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs'; import type { ReplicationOptions, ReplicationPullOptions, ReplicationPushOptions, RxCollection, RxDocumentData, RxError, RxReplicationPullStreamItem, RxStorageInstance, RxStorageInstanceReplicationState, RxStorageReplicationMeta, RxTypeError, WithDeleted } from '../../types'; export declare const REPLICATION_STATE_BY_COLLECTION: WeakMap[]>; export declare class RxReplicationState { /** * hash of the identifier, used to flag revisions * and to identify which documents state came from the remote. */ readonly replicationIdentifierHash: string; readonly collection: RxCollection; readonly deletedField: string; readonly pull?: ReplicationPullOptions | undefined; readonly push?: ReplicationPushOptions | undefined; readonly live?: boolean | undefined; retryTime?: number | undefined; autoStart?: boolean | undefined; readonly subs: Subscription[]; readonly subjects: { received: Subject>; send: Subject>; error: Subject; canceled: BehaviorSubject; active: BehaviorSubject; }; readonly received$: Observable>; readonly send$: Observable>; readonly error$: Observable; readonly canceled$: Observable; readonly active$: Observable; private startPromise; constructor( /** * hash of the identifier, used to flag revisions * and to identify which documents state came from the remote. */ replicationIdentifierHash: string, collection: RxCollection, deletedField: string, pull?: ReplicationPullOptions | undefined, push?: ReplicationPushOptions | undefined, live?: boolean | undefined, retryTime?: number | undefined, autoStart?: boolean | undefined); private callOnStart; internalReplicationState?: RxStorageInstanceReplicationState; metaInstance?: RxStorageInstance; remoteEvents$: Subject>; start(): Promise; isStopped(): boolean; awaitInitialReplication(): Promise; /** * Returns a promise that resolves when: * - All local data is replicated with the remote * - No replication cycle is running or in retry-state * * WARNING: USing this function directly in a multi-tab browser application * is dangerous because only the leading instance will ever be replicated, * so this promise will not resolve in the other tabs. * For multi-tab support you should set and observe a flag in a local document. */ awaitInSync(): Promise; reSync(): void; emitEvent(ev: RxReplicationPullStreamItem): void; cancel(): Promise; } export declare function replicateRxCollection({ replicationIdentifier, collection, deletedField, pull, push, live, retryTime, waitForLeadership, autoStart, }: ReplicationOptions): RxReplicationState; export declare function startReplicationOnLeaderShip(waitForLeadership: boolean, replicationState: RxReplicationState): Promise;