Skip to main content

MessageBusExtensions

Trait MessageBusExtensions 

Source
pub trait MessageBusExtensions {
    // Required method
    fn as_message_bus(&self) -> Rc<dyn IMessageBus>;

    // Provided methods
    fn with_message_bus(&self) -> Rc<dyn IDisposable> { ... }
    fn with<R>(&self, block: impl FnOnce() -> R) -> R { ... }
}
Expand description

Runs code with a message bus as MessageBus::current (MessageBusExtensions).

Deviation (DEVIATIONS.md, ReactiveUI): the current message bus is per thread, so upstream’s lock (Monitor.Enter(messageBusGate)), which keeps the tests of other threads from replacing it in between, is not needed and not ported.

Required Methods§

Source

fn as_message_bus(&self) -> Rc<dyn IMessageBus>

The message bus as the handle that MessageBus::current holds.

Provided Methods§

Source

fn with_message_bus(&self) -> Rc<dyn IDisposable>

Makes the message bus MessageBus::current until the returned disposable is disposed, which restores the message bus that was current before (WithMessageBus).

Source

fn with<R>(&self, block: impl FnOnce() -> R) -> R

Runs block with the message bus as MessageBus::current and returns its result; the message bus current before is restored afterwards, also when block panics (With<TRet>(Func<TRet>), and With(Action) with a block that returns ()).

Not ported: the ArgumentException of a null block - argument validation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MessageBusExtensions for Rc<dyn IMessageBus>

Source§

impl<B: IMessageBus + 'static> MessageBusExtensions for Rc<B>

Implementors§