https://kotlinlang.org logo
Title
v

voddan

06/03/2019, 12:39 PM
@elizarov In the article you write that one should not use
withContext
inside a
flow{}
, basically. Can there be a realistic situation when such use is permitted? Maybe if
emit
is outside of
withContext
, or there are several `nested
withContext
that work in a way that protect the caller's context?
e

elizarov

06/03/2019, 1:49 PM
You can use
withContext
, but cannot
emit
from a different context.
p

Paul Woitaschek

06/04/2019, 9:33 PM
Also be careful because if you use
withContext
, you might receive elements after the job was cancelled, even if you're cancelling on the same thread: https://github.com/Kotlin/kotlinx.coroutines/issues/1177