https://kotlinlang.org logo
#coroutines
Title
# coroutines
z

Zach Klippenstein (he/him) [MOD]

01/27/2021, 2:57 PM
The docs on
MutableSharedFlow
are unclear, and I haven’t had enough coffee this morning to figure it out from looking at the code: if there’s no buffer and no replay, is there any difference between
DROP_OLDEST
and
DROP_LATEST
? I don’t think there should be, since if there’s no buffer, and no subscriber waiting for a value at the time of emission, the only thing to do is drop the value and there’s no concept of the “oldest” or “latest” value, just “the value trying to be emitted”.
p

pawegio

01/27/2021, 3:07 PM
there’s
IllegalArgumentException
thrown for both
DROP_OLDEST
 and 
DROP_LATEST
Copy code
require(replay > 0 || extraBufferCapacity > 0 || onBufferOverflow == BufferOverflow.SUSPEND) {
    "replay or extraBufferCapacity must be positive with non-default onBufferOverflow strategy $onBufferOverflow"
}
z

Zach Klippenstein (he/him) [MOD]

01/27/2021, 3:14 PM
Yep, need more coffee. Thanks
I think the docs could be more clear though, I’ll post a PR to try to clarify
3 Views