RLMAsyncOpenTask

Objective-C


@interface RLMAsyncOpenTask : NSObject

Swift

@_nonSendable(_assumed) class RLMAsyncOpenTask : NSObject, @unchecked Sendable

A task object which can be used to observe or cancel an async open.

When a synchronized Realm is opened asynchronously, the latest state of the Realm is downloaded from the server before the completion callback is invoked. This task object can be used to observe the state of the download or to cancel it. This should be used instead of trying to observe the download via the sync session as the sync session itself is created asynchronously, and may not exist yet when -[RLMRealm asyncOpenWithConfiguration:completion:] returns.

  • Deprecated

    Use addSyncProgressNotificationBlock instead

    Register a progress notification block.

    Each registered progress notification block is called whenever the sync subsystem has new progress data to report until the task is either cancelled or the completion callback is called. Progress notifications are delivered on the main queue.

    Declaration

    Objective-C

    - (void)addProgressNotificationBlock:
        (nonnull RLMProgressNotificationBlock)block;

    Swift

    func addProgressNotificationBlock(_ block: @escaping RLMProgressNotificationBlock)
  • Register a progress notification block.

    Each registered progress notification block is called whenever the sync subsystem has new progress data to report until the task is either cancelled or the completion callback is called. Progress notifications are delivered on the main queue.

    Declaration

    Objective-C

    - (void)addSyncProgressNotificationBlock:
        (nonnull RLMSyncProgressNotificationBlock)block;

    Swift

    func addSyncProgressNotificationBlock(_ block: @escaping RLMSyncProgressNotificationBlock)
  • Deprecated

    Use addSyncProgressNotificationOnQueue instead

    Register a progress notification block which is called on the given queue.

    Each registered progress notification block is called whenever the sync subsystem has new progress data to report until the task is either cancelled or the completion callback is called. Progress notifications are delivered on the supplied queue.

    Declaration

    Objective-C

    - (void)addProgressNotificationOnQueue:(nonnull dispatch_queue_t)queue
                                     block:(nonnull RLMProgressNotificationBlock)
                                               block;

    Swift

    func addProgressNotification(on queue: dispatch_queue_t, block: @escaping RLMProgressNotificationBlock)
  • Register a progress notification block which is called on the given queue.

    Each registered progress notification block is called whenever the sync subsystem has new progress data to report until the task is either cancelled or the completion callback is called. Progress notifications are delivered on the supplied queue.

    Declaration

    Objective-C

    - (void)
        addSyncProgressNotificationOnQueue:(nonnull dispatch_queue_t)queue
                                     block:
                                         (nonnull RLMSyncProgressNotificationBlock)
                                             block;

    Swift

    func addSyncProgressNotification(on queue: dispatch_queue_t, block: @escaping RLMSyncProgressNotificationBlock)
  • Cancel the asynchronous open.

    Any download in progress will be cancelled, and the completion block for this async open will never be called. If multiple async opens on the same Realm are happening concurrently, all other opens will fail with the error “operation cancelled”.

    Declaration

    Objective-C

    - (void)cancel;

    Swift

    func cancel()