Describe the bug
When an event is fired and has two listeners they share a reference to a single instance.
Expected behaviour
Listeners should have separated instance references. The event should only be mutated by middleware. This might be easier to implement for messages as their payload gets serialized.
Maybe we could create a new class that extends Event such as CloneableEvent which will have an abstract method clone () -> CloneableEvent. The programmer still can use unsafe Event, but for libraries (and Exteranto events), CloneableEvent could be used.
Describe the bug
When an event is fired and has two listeners they share a reference to a single instance.
Expected behaviour
Listeners should have separated instance references. The event should only be mutated by middleware. This might be easier to implement for messages as their payload gets serialized.
Maybe we could create a new class that extends
Eventsuch asCloneableEventwhich will have an abstract methodclone () -> CloneableEvent. The programmer still can use unsafeEvent, but for libraries (and Exteranto events),CloneableEventcould be used.