import {EventEmitter} from 'events'; import {Logger} from './logger'; import {Platform} from './platform'; declare class ReplicantCommon extends EventEmitter { log: Logger; name: string; opts: ReplicantOptions; revision: number; validate(value?: V, options?: {throwOnInvalid?: boolean}): boolean; once(event: 'change', listener: (value: V) => R): R; once(event: string, listener: (...args: any[]) => R): R; } export class ReplicantServer extends ReplicantCommon { constructor(name: string, namespace?: string, opts?: ReplicantOptions); value: V; namespace?: string; on( event: 'change', listener: ( newValue: V, oldValue?: V, operationQueue?: OperationQueueItem[] ) => void ): this; [prop: string]: any; } export class ReplicantBrowser extends ReplicantCommon { static declaredReplicants(): DeclaredReplicants<'browser'>; constructor( name: string, namespace: string, opts: ReplicantOptions, socket: SocketIOClient.Socket ); value?: V; namespace: string; status: 'undeclared' | 'declared' | 'declaring'; on(event: 'declared' | 'fullUpdate', listener: (data: V) => void): this; on( event: 'change', listener: (newValue: V, oldValue: V, dataOperations: any[]) => void ): this; on( event: | 'operationsRejected' | 'assignmentRejected' | 'declarationRejected', listener: (rejectReason: any) => void ): this; [prop: string]: any; } export type Replicant = P extends 'browser' ? ReplicantBrowser : ReplicantServer; /** * Replicant queue object */ export interface OperationQueueItem { path: string; method: string; args: any[]; } /** * Declared replicant store object */ export interface DeclaredReplicants

{ [bundleName: string]: {[replicantName: string]: Replicant}; } /** * Options to pass to Replicant constructor */ export interface ReplicantOptions { defaultValue?: V; persistent?: boolean; persistenceInterval?: number; schemaPath?: string; }