File tree Expand file tree Collapse file tree
Application/DevLogPresentation/Sources/Home/Home Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,13 +13,17 @@ import DevLogDomain
1313@MainActor
1414@Observable
1515final class HomeViewCoordinator {
16+ private enum AsyncStreamTaskID {
17+ case todoMutationEvent
18+ }
19+
1620 let viewModel : HomeViewModel
1721 let router = NavigationRouter < HomeRoute > ( )
1822 private let container : DIContainer
1923 @ObservationIgnored
2024 private var cancellable : AnyCancellable ?
2125 @ObservationIgnored
22- private var mutationTask : Task < Void , Never > ?
26+ private var streamTasks = [ AsyncStreamTaskID : Task < Void , Never > ] ( )
2327
2428 init ( container: DIContainer ) {
2529 self . container = container
@@ -37,7 +41,7 @@ final class HomeViewCoordinator {
3741 }
3842
3943 deinit {
40- mutationTask ? . cancel ( )
44+ streamTasks . values . forEach { $0 . cancel ( ) }
4145 }
4246
4347 func fetchData( ) {
@@ -49,10 +53,10 @@ final class HomeViewCoordinator {
4953 }
5054
5155 func bindTodoMutationEvent( ) {
52- guard mutationTask == nil else { return }
56+ guard streamTasks [ . todoMutationEvent ] == nil else { return }
5357
5458 let bus = container. resolve ( TodoMutationEventBus . self)
55- mutationTask = Task { [ weak self] in
59+ streamTasks [ . todoMutationEvent ] = Task { [ weak self] in
5660 let events = await bus. events ( )
5761 for await event in events {
5862 switch event {
You can’t perform that action at this time.
0 commit comments