Db Replication
Functions
Functions
createMetricsStorage
Create a metrics storage instance with default configuration
Signature:
createMetricsStorage(config?: Partial<StorageConfig> | undefined): ReplicationMetricsStorage
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
config | Partial<StorageConfig> | undefined | No |
Returns:
ReplicationMetricsStorage -
statusToSnapshot
Convert ReplicationStatus to MetricSnapshot
Signature:
statusToSnapshot(status: ReplicationStatus): MetricSnapshot
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
status | ReplicationStatus | Yes |
Returns:
MetricSnapshot -
createThrottledFunction
Create throttled version of a function with performance tracking
Signature:
createThrottledFunction(fn: T, wait: number, options?: { leading?: boolean; trailing?: boolean; trackPerformance?: boolean; }): T & { flush: () => void; cancel: () => void; }
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
fn | T | Yes | |
wait | number | Yes | |
options | { leading?: boolean; trailing?: boolean; trackPerformance?: boolean; } | No |
Returns:
T & { flush: () => void; cancel: () => void; } -
createDebouncedFunction
Create debounced version of a function with performance tracking
Signature:
createDebouncedFunction(fn: T, wait: number, options?: { leading?: boolean; trailing?: boolean; maxWait?: number; trackPerformance?: boolean; }): T & { flush: () => void; cancel: () => void; }
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
fn | T | Yes | |
wait | number | Yes | |
options | { leading?: boolean; trailing?: boolean; maxWait?: number; trackPerformance?: boolean; } | No |
Returns:
T & { flush: () => void; cancel: () => void; } -
ReplicationProvider
Signature:
ReplicationProvider({
children,
authToken,
domainId,
userId,
serverUrl,
serverProtocol
}: ReplicationProviderProps): React.JSX.Element
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| `{ | |||
| children, | |||
| authToken, | |||
| domainId, | |||
| userId, | |||
| serverUrl, | |||
| serverProtocol | |||
| }` | ReplicationProviderProps | Yes |
Returns:
React.JSX.Element -
createRecoveryManager
Create a default recovery manager instance
Signature:
createRecoveryManager(config?: Partial<RecoveryConfig> | undefined): ReplicationRecoveryManager
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
config | Partial<RecoveryConfig> | undefined | No |
Returns:
ReplicationRecoveryManager -
isRecoverableError
Determine if an error is recoverable
Signature:
isRecoverableError(error: Error): boolean
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
error | Error | Yes |
Returns:
boolean -
getSuggestedStrategies
Get suggested recovery strategies for an error
Signature:
getSuggestedStrategies(error: Error): string[]
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
error | Error | Yes |
Returns:
string[] -
withRetryRecovery
Create retry observable with recovery
Signature:
withRetryRecovery(source: Observable<T>, context: RecoveryContext, recoveryManager?: ReplicationRecoveryManager | undefined): Observable<T>
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
source | Observable<T> | Yes | |
context | RecoveryContext | Yes | |
recoveryManager | ReplicationRecoveryManager | undefined | No |
Returns:
Observable<T> -
useReplicationMonitoring
Enhanced replication monitoring hook with comprehensive RxDB observable integration Provides real-time monitoring of replication states, events, and performance metrics
Signature:
useReplicationMonitoring(options?: UseReplicationMonitoringOptions): UseReplicationMonitoringReturn
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options | UseReplicationMonitoringOptions | No |
Returns:
UseReplicationMonitoringReturn -
useReplicationSync
React hook for managing replication sync with authentication
Signature:
useReplicationSync(options: UseReplicationSyncOptions): { status: ReplicationStatus; startSync: () => Promise<void>; stopSync: () => void; forceSync: () => Promise<void>; isReady: boolean; }
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options | UseReplicationSyncOptions | Yes |
Returns:
{ status: ReplicationStatus; startSync: () => Promise<void>; stopSync: () => void; forceSync: () => Promise<void>; isReady: boolean; } -
withReplicationSync
Higher-order component for automatic replication sync
Signature:
withReplicationSync(Component: React.ComponentType<P>, options: UseReplicationSyncOptions): (props: P) => React.JSX.Element
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
Component | React.ComponentType<P> | Yes | |
options | UseReplicationSyncOptions | Yes |
Returns:
(props: P) => React.JSX.Element -
useRxdbServerReplication
Hook for RxDB server replication using the official RxDB server replication plugin Connects to the RxDB server running at https://localhost:3443 (nginx HTTP/3 reverse proxy)
Signature:
useRxdbServerReplication(config: RxdbServerReplicationConfig): RxdbServerReplicationState
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
config | RxdbServerReplicationConfig | Yes |
Returns:
RxdbServerReplicationState -
useMultipleRxdbServerReplications
Hook for managing multiple collection replications
Signature:
useMultipleRxdbServerReplications(collections: { collection: RxCollection; name: string; }[], config?: Partial<Omit<RxdbServerReplicationConfig, "collection" | "collectionName">> | undefined): { replications: RxdbServerReplicationState[]; isAllConnected: boolean; isAnyReplicating: boolean; hasErrors: boolean; totalDocs: number; totalPending: number; startAll: () => void; stopAll: () => void; restartAll: () => void; }
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
collections | { collection: RxCollection; name: string; }[] | Yes | |
config | Partial<Omit<RxdbServerReplicationConfig, "collection" | "collectionName">> | undefined | No |
Returns:
{ replications: RxdbServerReplicationState[]; isAllConnected: boolean; isAnyReplicating: boolean; hasErrors: boolean; totalDocs: number; totalPending: number; startAll: () => void; stopAll: () => void; restartAll: () => void; } -
convertToUTC
Convert a date to UTC ISO 8601 string format
Signature:
convertToUTC(date: string | Date): string
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
date | string | Date | Yes |
Returns:
string -
fromUTC
Convert UTC string to local Date object
Signature:
fromUTC(utcString: string): Date
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
utcString | string | Yes |
Returns:
Date -
formatUTC
Format UTC date string for display
Signature:
formatUTC(utcString: string, formatString?: string): string
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
utcString | string | Yes | |
formatString | string | No |
Returns:
string -
getCurrentUTC
Get current UTC timestamp as ISO string
Signature:
getCurrentUTC(): string
Returns:
string -
isValidUTC
Check if a string is valid UTC ISO 8601 format
Signature:
isValidUTC(dateString: string): boolean
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dateString | string | Yes |
Returns:
boolean -