Trait design_pattern_examples_rust::observer::observer_inumberchanged_trait::IObserverNumberChanged
source · pub trait IObserverNumberChanged {
// Required method
fn notify(&mut self, updated_number: u32);
}
Expand description
Represents an observer to the ObserverNumberProducer struct. An observer implements this trait and then subscribes to the ObserverNumberProducer struct with the trait. The observer will be called whenever a change in the number is made.
This trait is specific to the ObserverNumberProducer struct example, which is a typical requirement for a subject that supports observers.
Required Methods§
sourcefn notify(&mut self, updated_number: u32)
fn notify(&mut self, updated_number: u32)
This is called whenever the number in the ObserverNumberProducer object is changed.
Parameters
- The updated number the observer is being told about.