diff --git a/Sources/TCACoordinators/TCARouter/TCARouter.swift b/Sources/TCACoordinators/TCARouter/TCARouter.swift index e9604fc..900bef8 100644 --- a/Sources/TCACoordinators/TCARouter/TCARouter.swift +++ b/Sources/TCACoordinators/TCARouter/TCARouter.swift @@ -17,10 +17,10 @@ public struct TCARouter< let updateRoutes: ([Route]) -> CoordinatorAction let action: (ID, ScreenAction) -> CoordinatorAction let identifier: (Screen, Int) -> ID - + @ObservedObject private var viewStore: ViewStore @ViewBuilder var screenContent: (Store) -> ScreenContent - + func scopedStore(index: Int, screen: Screen) -> Store { var screen = screen return store.scope( @@ -34,16 +34,16 @@ public struct TCARouter< } ) } - + public var body: some View { Router( - viewStore.binding(get: { _ in store.withState(routes) }, send: updateRoutes), + ViewStore(store, observe: { $0 }).binding(get: routes, send: updateRoutes), buildView: { screen, index in screenContent(scopedStore(index: index, screen: screen)) } ) } - + public init( store: Store, routes: @escaping (CoordinatorState) -> [Route],