# BrokerObserver

As for the [PropertyObserver](https://docs.radicalframework.com/release-2/concepts/observers/property-observer) or the [MementoObserver](https://docs.radicalframework.com/release-2/concepts/observers/memento-observer) the BrokerObserver is an easy shortcut to react to message arrivals when using [the message broker](https://github.com/RadicalFx/documentation/tree/3593d0c5b04875dd1fb6be74908fc5cea4ac1a8d/messaging/message-broker.md).

```csharp
var monitor = BrokerObserver.Using(aBrokerInstance)
    .WaitingFor<MySampleMessage>();
```

We can use a monitor to trigger, for example, the `CanExecuteChanged` event of a `ICommand` interface implementation:

```csharp
var monitor = BrokerObserver.Using(aBrokerInstance)
    .WaitingFor<MySampleMessage>();

DelegateCommand.Create()
    .OnCanExecute(state =>
    {
        //evaluate if the command can be executed.
        return true;
    })
    .OnExecute(state =>
    {
        //execute the command
    })
    .AddMonitor(monitor);
```

What the above code does is to trigger the `CanExecuteChanged` logic each time a message of type `MySampleMessage` is delivered via the monitored message broker.
