s
-.txt
g
This code will hang forever because coroutineScope never return because produce coroutine will never finish
s
ah yeah will need to wrap the while in async { } I guess
g
no, this code semantically incorrect, you have to pass coroutine scope to launch produce as any other coroutine
Function coroutineScope just will not work with such use case because coroutineScope suspend until all child coroutines are finished
s
hmmm Id need to use withContext(dispatcher.someother) { } inside produce ?
g
Why? no
This is now what I want to say. I meant that
coroutineScope{}
is special kind of scope builder that created to use as suspend function, but it just cannot be used with produce inside, because design to suspend until all child coroutines will finish
Copy code
suspend fun CoroutineScope.createChangeStream() : ReceiveChannel<String> {
        return produce<String> {
                while(true) {
                    send("Changed")
                    delay(1000)
                }
        }
    }
👍 1
just use this approach