Hi,
Is it possible in kotlin to filter element of list by these type.
My list contain element which are generic
IEventSubsriber
where IDomainEvent is en interface:
This is the model :
interface IDomainEvent
data class WarriorCreated(val content: String): IDomainEvent
data class WarriorDeleted(val content: String = ""): IDomainEvent
I thied with the methode of List : filterIsInstance() but with no success.
To be more precise this is my use case.
I receive an event of type IDomainEvent which can be a WarriorCreated or WarriorDeleted and depending of the tkind of IDomainEvent I want to retrieves only subscribers of the desired type
private val subscribers = mutableSetOf<>()<IEventSubsriber<IDomainEvent>> >()
override fun publish(evt: IDomainEvent) {
// filter susribers by kind of events
}
Thanks and regards