Lukas K-G
03/09/2026, 7:50 AMinterface Player : EventEmitter<PlayerEvent> {
fun play() // completion: PlayerEvent.Playing / PlayerEvent.Error
....
}
We want to add suspending variants that await the corresponding completion event. The existing non-suspend API must stay as-is since we don't want to break backwards compatibility.
What's the idiomatic Kotlin approach here? Is there an established pattern we're missing?Dmitry Khalanskiy [JB]
03/09/2026, 12:31 PMLukas K-G
03/09/2026, 12:58 PMsuspend awaitPlay()? Same name overloads don't seem to work (i.e. suspend play()).Lukas K-G
03/09/2026, 12:59 PMDmitry Khalanskiy [JB]
03/09/2026, 1:22 PMsuspend method pairs, so I'm not sure there is an established naming convention for that scenario.
An approach I've seen in the wild is to have two separate interfaces: Player and AsyncPlayer, with fun Player.asAsyncPlayer(): AsyncPlayer. Then, AsyncPlayer could also have suspend fun play().Lukas K-G
03/09/2026, 1:35 PM