LiveData Observer is not working in jetpack compose

38 views Asked by At
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        viewModel.isDialogOpen.observe(viewLifecycleOwner) { isDialogOpen ->
            if (!isDialogOpen) {
                [email protected]()
            }
        }
fun saveConfiguration() {
        if (saveJob == null) {
            saveJob = viewModelScope.launch {
                withContext(Dispatchers.IO) {
                    setUpProfile()
                    L.saveState(
                    withContext(Dispatchers.Main) {
                        context.sendBroadcast(Intent (FloorPlanFragment.ACTION_BLE_PAIRING_COMPLETED));
                        ProgressDialogUtils.hideProgressDialog()
                        _isDialogOpen.value = false
                    }
                }

                // This check is needed because the dialog sometimes fails to close inside the coroutine.
                // We don't know why this happens.
                if (ProgressDialogUtils.isDialogShowing()) {
                    ProgressDialogUtils.hideProgressDialog()
                    _isDialogOpen.value = false
                }
            }
        }
    }

I have set btn when I clikced the set btn it set the Live data variable (isDialogOpen) to false ,but sometimes observe is not observing it .It is not coming inside the if condition

0

There are 0 answers