MutableStateFlow difference between value and emit

emit() is a suspend function that wraps a call to set the value:

override suspend fun emit(value: T) {
    this.value = value
}

So the difference is that value lets you set the value even when not in a coroutine. emit() exists so MutableStateFlow can inherit from MutableSharedFlow.

Source code here.

Leave a Comment