I have sharedflow in the shared module, once the n...
# multiplatform
p
I have sharedflow in the shared module, once the network call is complete I want to navigate to InfoScreen in swiftui however , each time I have to emit the effect two times , sometimes more , plz help @MainActor
Copy code
class FoodDetailsViewModel: ObservableObject {
  @Published var shouldNavigateTolInfo = false
   
  init() {
    viewModelKt.uiState.collectFlow(onCollect: { state in
      self.uiState = state!
    }
    )
     
    viewModelKt.sideEffects.collectFlow(onCollect: { effect in
      if effect is FoodDetailsViewModelContractSideEffect.NavigateToInfo {
        self.shouldNavigateToInfo = true
      }
    })
  }
}
Copy code
@StateObject var viewModel = FoodDetailsViewModel()
in the view
Text("Food".onChange(of: viewModel.shouldNavigateTolInfo) { value in
      if value {
        viewModel.shouldNavigateTolInfo = false
        appNavigationState.path.append(Destinations.InfoScreen)
      }
    }
kodee happy 1
🦜 1
pepechains 1
🦜 1