Replies: 1 comment 2 replies
-
Hello @tobitech ,
You can take an idea from: https://github.com/pointfreeco/isowords/blob/main/Sources/ApiClientLive/LiveKey.swift#L15 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm thinking of a way to go about designing dependencies whose live implementation requires an initial setup/configuration of a 3rd party framework.
In my case I have a DataStoreClient whose live implementation uses Realm SDK for loading and storing data.
I need to configure a Realm object that is accessible to other closures in the client.
I achieved this with an optional variable that was initialised in the setup closure prior to migrating from
Effect<>
toasync-await
which also meant I needed to mark the closures with @sendable.The moment I do that I start getting the error
Reference to captured var 'realm' in concurrently-executing code
which was expected so I captured the mutable variable in the closure.The problem I'm having now is that when the instance of the client is initialised, the closures capture a nil value of the realm variable and I'm not able to access the non-nil value after
setupConfigurations
closure is called.Interface
Live Implementation
I don't know how you guys have approached this problem when designing dependencies with structs, would appreciate some help and suggestions.
Beta Was this translation helpful? Give feedback.
All reactions