ruex/prelude/notifier.rs
1use std::fmt::Debug;
2
3use super::Interest;
4
5/// The definition for a PureMVC Notifier.
6///
7/// [MacroCommand, Command, Mediator] and [Proxy]
8/// all have a need to send [Notification]'s.
9///
10/// The [Notifier] interface provides a common method called
11/// [send] that relieves implementation code of
12/// the necessity to actually construct [Notification]'s.
13///
14/// The [Notifier] class, which all of the above mentioned classes
15/// extend, also provides an initialized reference to the [Facade]
16/// Singleton, which is required for the convienience method
17/// for sending [Notification]'s, but also eases implementation as these
18/// classes have frequent [Facade] interactions and usually require
19/// access to the facade anyway.
20///
21/// [Notification]: crate::prelude::Notification
22/// [Facade]: crate::prelude::Facade
23/// [MacroCommand]: crate::prelude::MacroCommand
24/// [Command]: crate::prelude::Command
25/// [Mediator]: crate::prelude::Mediator
26/// [Proxy]: crate::prelude::Proxy
27/// [send]: Notifier::send
28
29pub trait Notifier<Body>
30where
31 Body: Debug + 'static,
32{
33 /// Send a [Notification].
34 ///
35 /// Convenience method to prevent having to construct new
36 /// notification instances in our implementation code.
37 ///
38 /// [Notification]: crate::prelude::Notification
39 fn send(&self, interest: Interest, body: Option<Body>);
40}