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

dave08

10/02/2017, 8:05 AM
Maybe a class that implements Handler and has a fun that returns a ProducerJob which sends anything the handler receives?
Or like this?
Copy code
class ProducerHandler<T>(val context: Context): Handler<T> {
	override fun handle(event: T) {
		launch(context.dispatcher()) {
			_channel.send(event)
		}
	}

	private val _channel = Channel<T>()

	val channel: ReceiveChannel<T> = _channel
}
3 Views