[feature]: Asserting values are present when viewmodel.dataReady is true #1118
Labels
Feedback Requested
Waiting for new information from the OP
Improvement
An issue to improve existing functionality
Is your feature request related to a problem? Please describe.
When using a FutureViewModel, !viewModel.dataReady is a nice helper to indicate whether the data has been loaded. When it is true, one can be sure that the values are there. However, I still need to use ! on the viewModel.data in this case, despite being sure that the data is there. This is error prone because I might use the ! in instances where the data is indeed not there.
Describe the solution you would like
I image some kind of assertion when viewModel.dataReady is true such that when viewModel.data is used under this scope, the non-null return type can be used.
For now i have written the following extension function such that i can use viewModel.safeData, but i think it might be possible to use viewModel.data, and deduce the information that the data is loaded.
Additional Context
The text was updated successfully, but these errors were encountered: