'How to remove previous stateflow observer before adding new one

what if I'm calling below method twice in loop? does it gonna call onEach method twice. the app driver flow is returning AppDriver object

private fun getDriverObj() {
        homeRepository.getAppDriverFlow()
            .flowOn(IO)
            .onEach {
                appDriver = it
                checkRequiredObjects()
//                signalRController.
//                signalRController.stopSocket()
//                signalRController = SignalRController()
            }
            .launchIn(CoroutineScope(IO))
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source