Currently, NavigationRoute can only be initialised using a property wrapper. However, protocols in Swift do not yet support property wrappers as properties.
There are cases where we'd like to define possible navigation routes in a protocol and allow the protocol’s conforming types to implement them. This PR makes the NavigationRoute initialiser public, allowing routes to be defined in protocols and instantiated without the need for a property wrapper in the implementation.
public protocol ScreenBProtocol: NavigationCoordinatable {}
public protocol ScreenAProtocol: NavigationCoordinatable {
associatedtype ScreenB: ScreenBProtocol
var screenB: NavigationRoute<Self, Presentation, (), ScreenB> { get }
}
public final class ScreenACoordinator<
ScreenB: ScreenBProtocol,
>: ScreenAProtocol {
public typealias I = ScreenACoordinator<ScreenB>
public let stack: Stinsen.NavigationStack<I>
@Root var root = makeRoot
public var screenB = NavigationRoute(wrappedValue: I.makeScreenB, .modal)
...
}
Currently,
NavigationRoute
can only be initialised using a property wrapper. However, protocols in Swift do not yet support property wrappers as properties.There are cases where we'd like to define possible navigation routes in a protocol and allow the protocol’s conforming types to implement them. This PR makes the NavigationRoute initialiser public, allowing routes to be defined in protocols and instantiated without the need for a property wrapper in the implementation.