I recently migrated from `PublishSubject.create&lt...
# coroutines
a
I recently migrated from
PublishSubject.create<T>()
to
MutableSharedFlow<T>(replay = 0, extraBufferCapacity = 1)
, but what I can't wrap my head around is what is the use case for
MutableSharedFlow<T>()
? (both parameters set to zero by default). It doesn't really seem to do anything.
g
MutableStateFlow is like BehaviourSubject, so it replay = 1 and onBufferOverflow = DROP_OLDEST
+ it always has default value (which is not true for BehaviourSubject)
a
Ah sorry, meant default constructor for MutableSharedFlow 😅
g
It doesn’t really seem to do anything
Isn’t it emit if it already have subscribers? I didn’t try, just asking Also default constructor uses Suspend overflow policty, so emitter will suspend in this case
a
I tried it very shortly and it seemed like it didn't emit to existing subscribers until I added the extra buffer capacity. But I was using tryEmit to post values instead of the suspending emit
g
. But I was using tryEmit to post values instead of the suspending emit
Probably this why you have this problem, tryEmit will just drop value
There is no way to avoid suspension without buffer
a
Ah that makes a lot of sense, thanks :)