A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/realm-sdks/swift/latest/Structs/AsyncOpen.html below:

AsyncOpen Structure Reference

AsyncOpen
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@MainActor
@propertyWrapper
public struct AsyncOpen : DynamicProperty

A property wrapper type that initiates a Realm.asyncOpen() for the current user which asynchronously open a Realm, and notifies states for the given process

Add AsyncOpen to your SwiftUI/View or SwiftUI/App, after a user is already logged in, or if a user is going to be logged in

@AsyncOpen(appId: "app_id", partitionValue: <partition_value>) var asyncOpen

This will immediately initiates a Realm.asyncOpen() operation which will perform all work needed to get the Realm to a usable state. (see Realm.asyncOpen() documentation)

This property wrapper will publish states of the current Realm.asyncOpen() process like progress, errors and an opened realm, which can be used to update the view

struct AsyncOpenView: View {
    @AsyncOpen(appId: "app_id", partitionValue: <partition_value>) var asyncOpen

    var body: some View {
       switch asyncOpen {
       case .notOpen:
           ProgressView()
       case .open(let realm):
           ListView()
              .environment(\.realm, realm)
       case .error(_):
           ErrorView()
       case .progress(let progress):
           ProgressView(progress)
       }
    }
}

This opened realm can be later injected to the view as an environment value which will be used by our property wrappers to populate the view with data from the opened realm

ListView()
   .environment(\.realm, realm)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4