https://kotlinlang.org logo
Title
e

Edouard Goossens

02/07/2019, 10:18 AM
Hi all. The following function returns a channel that I later use with “consumeEach”. However, the receiver keeps getting COROUTINE_SUSPENDED. What am I not understanding/doing wrong?
actual fun observe(): ReceiveChannel<DocumentSnapshot> {
        val channel = Channel<DocumentSnapshot>(Channel.CONFLATED)
        val removeListener = documentReference.onSnapshot({
            channel.offer(DocumentSnapshot(it))
        }, {
            channel.close(it)
        })
        channel.invokeOnClose { removeListener() }
        return channel
}
This code was compiled into NodeJS modules. It seems there is some kind of conflict when two NodeJS modules use their own copies of the coroutines JS library (each it’s own file in node_modules). Merging kotlin sources and producing a single NodeJS module solved this.