Skip to content

Commit

Permalink
Don't activate vm state observation if set to false in init
Browse files Browse the repository at this point in the history
  • Loading branch information
kaulex99 committed May 12, 2024
1 parent 5160d7d commit 362030b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions WaiterRobot/Core/Mvi/ObservableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class ObservableViewModel<State: ViewModelState, Effect: ViewModelEffect, ViewMo

private var task: Task<Void, Error>? = nil

init(viewModel: ViewModel, subscribe _: Bool = true) {
init(viewModel: ViewModel, subscribe: Bool = true) {
actual = viewModel
// This is save, as the constraint is required by the generics (S must be the state of the provided VM)
state = actual.container.stateFlow.value as! State

Task {
await activate()
if subscribe {
Task {
await activate()
}
}
}

Expand Down

0 comments on commit 362030b

Please sign in to comment.