[−][src]Trait revent::Node
Describes a subscriber that can subscribe to Anchor.
use revent::{Anchor, Manager, Slot, Node}; use std::{cell::RefCell, rc::Rc}; trait A {} struct MyAnchor { a: Slot<dyn A>, manager: Manager, } impl Anchor for MyAnchor { fn manager(&self) -> &Manager { &self.manager } } // --- struct MyNode; impl Node<MyAnchor, ()> for MyNode { fn register_emits(_: &MyAnchor) -> () { () } fn register_listens(slots: &mut MyAnchor, item: Rc<RefCell<Self>>) { slots.a.register(item); } const NAME: &'static str = "MyNode"; } impl A for MyNode {}
Associated Constants
const NAME: &'static str
Unique name of the node.
Used for figuring out recursions and graphing channel dependencies.
Required methods
fn register_emits(anchor: &A) -> T
Create an object containing clones of the anchor's signals.
Typically constructs a struct which is stored in Self
. This struct is given
Anchor::subscribe's create function.
May return ()
if no further signals are sent from this node.
fn register_listens(anchor: &mut A, item: Rc<RefCell<Self>>)
Register to various channels inside an Anchor.
Note that this function is used for both subscribe as well as
unsubscribe. So this function ought to not depend on the state of the
item. If it does, then a node may still be subscribed to some channels after
unsubscribe
has been called.