OpenBehavior

@frozen
public enum OpenBehavior : Sendable

Options for when to download all data from the server before opening a synchronized Realm.

  • Immediately return the Realm as if the synchronous initializer was used. If this is the first time that the Realm has been opened on this device, the Realm file will initially be empty. Synchronized Realms will contact the server and download new data in the background.

    Declaration

    Swift

    case never
  • Always open the Realm asynchronously and download all data from the server before returning the Realm. This mode will fail to open the Realm if the device is currently offline.

    Declaration

    Swift

    case always
  • Open the Realm asynchronously the first time it is opened on the current device, and then synchronously afterwards. This mode is suitable if you wish to wait to download the server-side data the first time your app is launched on each device, but afterwards support offline launches using the existing local data.

    Note that if .once is used multiple times simultaneously then calls after the first may see partial local data from the first call and not wait for the download.

    Declaration

    Swift

    case once