You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
private static let dependencies = Dependencies {
Module { AccountStore.shared as AccountDataSource }
Module { RealmStore.shared as RealmStore }
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Self.dependencies.build()
...
I expected that as soon as a view model with an @Inject that is not in the dependencies would crash. In reality, it crashes on usage of that Inject (which was pretty surprising).
final class BrokenViewModel {
@Inject var accountStore: AccountDataStore
@Inject var realmStore: RealmStore
@Inject var otherStore: OtherStore
init() {
// Use accountStore and realmStore - no problemo
}
func foo() {
otherStore.bar() // CRASH
}
I would have assumed on instantiation of BrokenViewModel that it would crash because the Injection couldn't be resolved?
The text was updated successfully, but these errors were encountered:
Right, it would crash on first use of the properties. I've been thinking of having a build process you'd put in a phase that would run the entire container to check and give an Xcode error if one of the dependencies are missing.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Using a creation pattern of:
I expected that as soon as a view model with an @Inject that is not in the dependencies would crash. In reality, it crashes on usage of that Inject (which was pretty surprising).
I would have assumed on instantiation of BrokenViewModel that it would crash because the Injection couldn't be resolved?
The text was updated successfully, but these errors were encountered: