AsyncOpenTask

public struct AsyncOpenTask

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 Realm.asyncOpen() returns.

  • 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

    Swift

    public func cancel()
  • 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 supplied queue.

    Declaration

    Swift

    public func addProgressNotification(queue: DispatchQueue = .main,
                                        block: @escaping (SyncSession.Progress) -> Void)

    Parameters

    queue

    The queue to deliver progress notifications on.

    block

    The block to invoke when notifications are available.