Animesh Sahu
05/14/2020, 7:39 AMStefan Beyer
05/14/2020, 9:27 AMclass CommunicatorImpl(
// ...
val broadcast: BroadcastChannel<Event<Any>>,
val receiver: Channel<Event<Any>>
) : Communicator {
// ...
}
then you do not need to think about those interface collisions. you just call myCommunicator.broadcast.cancel(...)
and myCommunicator.receiver.cancel(...)
cancelling both at the same time would be done via a method
class CommunicatorImpl(
// ...
) : Communicator {
// ...
fun cancel(cause: Throwable? = null) {
// translate cause into CancellationException
// cancel both channels here
}
}
Animesh Sahu
05/14/2020, 9:28 AMStefan Beyer
05/14/2020, 9:32 AMmyCommunicator.broadcast.otherFunction()
. it is a bit more verbose to call these, but on the flipside, the caller knows in what context this call is executed.Animesh Sahu
05/14/2020, 9:37 AMAnimesh Sahu
05/14/2020, 9:38 AMStefan Beyer
05/14/2020, 9:44 AMCommunicator
interface and manually mapping all the methods.
if design does not matter and this is just from the technical aspect of the question: this is not possible to my knowledge. you would need type classes or similar concepts for this to work.Animesh Sahu
05/14/2020, 9:46 AMAnimesh Sahu
05/14/2020, 9:46 AM