fun test() = runBlocking { val subject = BehaviorProcessor.create() val channel = BroadcastChannel(1) subject .subscribe { println(it) } val job = launch(Dispatchers.Default) { channel.asFlow() .collect { subject.offer(it) } } channel.offer("Hello") channel.offer("World") job.join() assert(channel.close()) }