# IMessageBus

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/interfaces/trait-imessagebus/

**trait** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
trait IMessageBus: IEnableLogger
```

A message bus: a simple way for view models and other objects to talk to each other without
knowing each other (`IMessageBus`).

Which messages go where is decided by the type of the message and a contract, a string that
tells apart the messages of the same type and that the client chooses.

The typed operations of upstream (`Listen<T>`, `SendMessage<T>`, `RegisterMessageSource<T>`,
`RegisterScheduler<T>`, ...) are the methods of `IMessageBusExt`,
which every shared handle of a bus (`Rc<MessageBus>`, `Rc<dyn IMessageBus>`) has; they go
through the methods of this trait.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/interfaces/i_message_bus.rs#L84)

## Members

- [`register_scheduler_for`](#function-register_scheduler_for)
- [`is_registered_with_contract`](#function-is_registered_with_contract)
- [`is_registered`](#function-is_registered)
- [`message_subject`](#function-message_subject)

<a id="function-register_scheduler_for"></a>

### register_scheduler_for

```rust
fn register_scheduler_for(self: &Self, key: MessageKey, scheduler: Rc<dyn IScheduler>)
```

Registers the scheduler that delivers the messages of a channel, replacing the one
registered before (`RegisterScheduler<T>(IScheduler, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/interfaces/i_message_bus.rs#L87)

<a id="function-is_registered_with_contract"></a>

### is_registered_with_contract

```rust
fn is_registered_with_contract(self: &Self, message_type: TypeId, contract: Option<&str>) -> bool
```

Whether the channel of `message_type` and `contract` is registered: a message was sent on
it, or something listened to it (`IsRegistered(Type, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/interfaces/i_message_bus.rs#L91)

<a id="function-is_registered"></a>

### is_registered

```rust
fn is_registered(self: &Self, message_type: TypeId) -> bool
```

Whether the channel of `message_type` without a contract is registered
(`IsRegistered(Type)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/interfaces/i_message_bus.rs#L95)

<a id="function-message_subject"></a>

### message_subject

```rust
fn message_subject(self: &Self, key: &MessageKey, create: &dyn Fn(Rc<dyn IScheduler>) -> Rc<dyn Any>) -> Rc<dyn Any>
```

The subject of the messages of a channel, created with `create` the first time, given the
scheduler registered for the channel (`SetupSubjectIfNecessary<T>`). The subject is an
`Rc<ScheduledSubject<T>>` of the type of the messages, type-erased.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/interfaces/i_message_bus.rs#L102)

## Trait implementations

- [`IMessageBus`](/docs/0.5.0/api/ferroui-reactiveui/interfaces/trait-imessagebus/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
