Domains/contexts are used to specify the range where events should occur and listened. That supports the reuse of
events (
Event
and listeners (
RemoteEventListener
.
Example:
Your application is a multiplayer online game with a conversation system. You defined the following events and
listeners.
Events: NewUserEvent
Listeners: ConversationListener, ConversationChannelListener, PlayerListListener
It makes sense to divide your elements into different domains, to ensure that a NewUserEvent affects only the right
context/domain. For example one conversation domain and one game domain. ConversationListener and
ConversationChannelListener should be added to the conversation domain and the PlayerListListener should be added to
the game domain. Now you can distinguish the context of the NewUserEvent. If a user joined a conversation (NewUserEvent
added to conversation domain), the two conversation listeners will recognize it and the PlayerListListener won't be
informed about the NewUserEvent in the conversation context/domain.