Skip to content

Commit

Permalink
Ensure viewmodel is unsubscribed when exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Jan 10, 2025
1 parent 0fab351 commit 792072c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class VariationsBulkUpdateBaseFragment(@LayoutRes layoutId: Int) : Base
viewModel.onDoneClicked()
true
}

else -> false
}
}
Expand All @@ -68,7 +69,12 @@ abstract class VariationsBulkUpdateBaseFragment(@LayoutRes layoutId: Int) : Base
ActivityUtils.hideKeyboard(requireActivity())
uiMessageResolver.showSnack(event.message)
}
is MultiLiveEvent.Event.Exit -> requireActivity().onBackPressedDispatcher.onBackPressed()

is MultiLiveEvent.Event.Exit -> {
// Ensure subsequent Exit events are ignored to avoid IllegalStateException
viewModel.event.removeObservers(viewLifecycleOwner)
requireActivity().onBackPressedDispatcher.onBackPressed()
}
}
}
}
Expand Down

0 comments on commit 792072c

Please sign in to comment.