Trait OptionsMonitor

Source
pub trait OptionsMonitor<T: Value> {
    // Required methods
    fn get(&self, name: Option<&str>) -> Ref<T>;
    fn on_change(
        &self,
        listener: Box<dyn Fn(Option<&str>, Ref<T>) + Send + Sync>,
    ) -> Subscription<T>;

    // Provided method
    fn current_value(&self) -> Ref<T> { ... }
}
Expand description

Defines the behavior for notifications when Options instances change.

Required Methods§

Source

fn get(&self, name: Option<&str>) -> Ref<T>

Returns a configured instance with the given name.

§Arguments
  • name - The name associated with the options.
Source

fn on_change( &self, listener: Box<dyn Fn(Option<&str>, Ref<T>) + Send + Sync>, ) -> Subscription<T>

Registers a callback function to be invoked when the configured instance with the given name changes.

§Arguments
  • listener - The callback function to invoke
§Returns

A change subscription for the specified options. When the subscription is dropped, no further notifications will be propagated.

Provided Methods§

Source

fn current_value(&self) -> Ref<T>

Returns the current instance with the default options name.

Implementors§