Florian
10/28/2020, 9:09 PMfirst()
because I only need to set the value from DataStore once, afterwards just clicking the checkbox will check/uncheck it. Does this make sense? Are there any situations where it will break?
2. Is the asynchronicity a problem? As far as I understand, you can't read from DataSore synchronously so this is the only option I can see.
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
[...]
viewLifecycleOwner.lifecycleScope.launch {
menu.findItem(R.id.action_hide_completed_tasks).isChecked =
viewModel.preferencesFlow.first().hideCompleted
}
}
louiscad
10/29/2020, 6:53 AMFlorian
10/29/2020, 9:52 AMfirst()
?louiscad
10/29/2020, 9:58 AMFlorian
10/29/2020, 10:19 AM