Extension function to update the state of a MutableStateFlow.
The type of the data.
A function to update the data.