-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
It would be nice if the framework allowed for lower scope to have an optional property provided by an ancestor scope with a non-optional of the same type. Like was once mentioned in #66 .
In addition it would be great if optional dependencies didn't have to be satisfied by an ancestor scope. Where if an optional dependency isn't provided by an ancestor it just returns nil.
This would allow for something like this:
final class LoggedOutComponent: BootstrapComponent {
func loggedInComponent(userName: String) -> LoggedInComponent {
return LoggedInComponent(userName: userName, parent: self)
}
var gameComponent: GameComponent {
return GameComponent(parent: self)
}
}
final class LoggedInComponent: Component<EmptyDependency> {
let userName: String
init(userName: String, parent: Scope) {
self.userName = userName
super.init(parent: parent)
}
var gameComponent: GameComponent {
return GameComponent(parent: self)
}
}
protocol GameDependency: Dependency {
var userName: String? { get }
}
final class GameComponent: Component<GameDependency> {}In this example, GameComponent has an optional dependency of userName that would be provided by LoggedInComponent when created from that scope, but would be nil when created from the LoggedOutComponent scope since there is no provider.
Metadata
Metadata
Assignees
Labels
No labels