/** * This plugin contains the primitives to create * a RxDB 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, RxJsonSchema, RxReplicationPullStreamItem, RxStorageInstance, RxStorageInstanceReplicationState, RxStorageReplicationMeta, RxTypeError, WithDeleted } from '../../types/index.d.ts'; export declare const REPLICATION_STATE_BY_COLLECTION: WeakMap[]>; export declare class RxReplicationState { /** * The identifier, used to flag revisions * and to identify which documents state came from the remote. */ readonly replicationIdentifier: 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; toggleOnDocumentVisible?: boolean | undefined; readonly subs: Subscription[]; readonly subjects: { received: Subject>; sent: Subject>; error: Subject; canceled: BehaviorSubject; active: BehaviorSubject; }; readonly received$: Observable>; readonly sent$: Observable>; readonly error$: Observable; readonly canceled$: Observable; readonly active$: Observable; wasStarted: boolean; readonly metaInfoPromise: Promise<{ collectionName: string; schema: RxJsonSchema>>; }>; startPromise: Promise; /** * start/pause/cancel/remove must never run * in parallel to avoid a wide range of bugs. */ startQueue: Promise; onCancel: (() => void)[]; constructor( /** * The identifier, used to flag revisions * and to identify which documents state came from the remote. */ replicationIdentifier: string, collection: RxCollection, deletedField: string, pull?: ReplicationPullOptions | undefined, push?: ReplicationPushOptions | undefined, live?: boolean | undefined, retryTime?: number | undefined, autoStart?: boolean | undefined, toggleOnDocumentVisible?: boolean | undefined); private callOnStart; internalReplicationState?: RxStorageInstanceReplicationState; metaInstance?: RxStorageInstance, any, {}, any>; remoteEvents$: Subject>; start(): Promise; _start(): Promise; pause(): Promise; isPaused(): boolean; isStopped(): boolean; isStoppedOrPaused(): 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; _cancel(doNotClose?: boolean): Promise; remove(): Promise; } export declare function replicateRxCollection({ replicationIdentifier, collection, deletedField, pull, push, live, retryTime, waitForLeadership, autoStart, toggleOnDocumentVisible }: ReplicationOptions): RxReplicationState; export declare function startReplicationOnLeaderShip(waitForLeadership: boolean, replicationState: RxReplicationState): Promise;