Skip to content
Anton edited this page Jul 5, 2024 · 7 revisions

Base

The Mediator pattern consists of two main parts:

  1. Dispatcher
  2. Observer

Dispatcher

Tip

Exactly one handler per request.

Returns result.

Raise HandleNotFoundError when no handler registered for the request.

Dispatcher - an entity that allows registering only one handler for a request.

If no handler is found for the request, a HandlerNotFoundError error will be thrown.

Additionally, the Dispatcher returns a result.

Observer

Tip

Many handlers per request.

No result.

Observer - an entity that allows registering multiple handlers for a single request.

If no registered handlers are found for the request, the program will continue execution.

The Observer does not return the execution result.

Implementation

Based on the Dispatcher, the following are built:

  1. QueryDispatcher
  2. CommandDispatcher

Based on the Observer, the following are built:

  1. EventObserver
Clone this wiki locally