CBLReplicator

@interface CBLReplicator : NSObject

A replicator for replicating document changes between a local database and a target database. The replicator can be bidirectional or either push or pull. The replicator can also be one-short or continuous. The replicator runs asynchronously, so observe the status property to be notified of progress.

  • The replicator’s configuration. The returned configuration object is readonly; an NSInternalInconsistencyException exception will be thrown if the configuration object is modified.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CBLReplicatorConfiguration *_Nonnull config;

    Swift

    var config: CBLReplicatorConfiguration { get }
  • The replicator’s current status: its activity level and progress. Observable.

    Declaration

    Objective-C

    @property (readonly, atomic) CBLReplicatorStatus *_Nonnull status;

    Swift

    var status: CBLReplicatorStatus { get }
  • Initializes a replicator with the given configuration.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithConfig:
        (nonnull CBLReplicatorConfiguration *)config;

    Swift

    init(config: CBLReplicatorConfiguration)
  • Not available

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Starts the replicator. This method returns immediately; the replicator runs asynchronously and will report its progress throuh the replicator change notification.

    Declaration

    Objective-C

    - (void)start;

    Swift

    func start()
  • Stops a running replicator. This method returns immediately; when the replicator actually stops, the replicator will change its status’s activity level to kCBLStopped and the replicator change notification will be notified accordingly.

    Declaration

    Objective-C

    - (void)stop;

    Swift

    func stop()
  • Resets the local checkpoint of the replicator, meaning that it will read all changes since the beginning of time from the remote database. This can only be called when the replicator is in a stopped state.

    Declaration

    Objective-C

    - (void)resetCheckpoint;

    Swift

    func resetCheckpoint()
  • Adds a replicator change listener. Changes will be posted on the main queue.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)addChangeListener:
        (nonnull void (^)(CBLReplicatorChange *_Nonnull))listener;

    Parameters

    listener

    The listener to post the changes.

    Return Value

    An opaque listener token object for removing the listener.

  • Adds a replicator change listener with the dispatch queue on which changes will be posted. If the dispatch queue is not specified, the changes will be posted on the main queue.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addChangeListenerWithQueue:(nullable dispatch_queue_t)queue
                          listener:(nonnull void (^)(CBLReplicatorChange *_Nonnull))
                                       listener;

    Parameters

    queue

    The dispatch queue.

    listener

    The listener to post changes.

    Return Value

    An opaque listener token object for removing the listener.

  • Adds a replication event listener. The replication event will be posted on the main queue.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)addDocumentReplicationListener:
        (nonnull void (^)(CBLDocumentReplication *_Nonnull))listener;

    Parameters

    listener

    The listener to post replication events.

    Return Value

    An opaque listener token object for removing the listener.

  • Adds a replication event listener with the dispatch queue on which replication events will be posted. If the dispatch queue is not specified, the replication events will be posted on the main queue.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addDocumentReplicationListenerWithQueue:(nullable dispatch_queue_t)queue
                                       listener:
                                           (nonnull void (^)(
                                               CBLDocumentReplication *_Nonnull))
                                               listener;

    Parameters

    queue

    The dispatch queue.

    listener

    The listener to post replication events.

    Return Value

    An opaque listener token object for removing the listener.

  • Removes a change listener with the given listener token.

    Declaration

    Objective-C

    - (void)removeChangeListenerWithToken:(nonnull id<CBLListenerToken>)token;

    Parameters

    token

    The listener token;