[][src]Trait revent::Anchor

pub trait Anchor where
    Self: Sized
{ fn manager(&self) -> &Manager; fn subscribe<R, T, F>(&mut self, create: F) -> Rc<RefCell<T>>
    where
        T: Node<Self, R>,
        F: FnOnce(R) -> T
, { ... }
fn unsubscribe<T, R>(&mut self, input: &Rc<RefCell<T>>)
    where
        T: Node<Self, R>
, { ... } }

A collection of channels to which Nodes can subscribe.

Anchors must be organized by a Manager, this is done by implementing a data structure containing various channels together with this trait.

A typical implementation may look like this:

use revent::{Anchor, feed::Feed, Manager, Single, Slot};
use std::{cell::RefCell, rc::Rc};

struct MyAnchor {
    a: Slot<()>,
    b: Single<()>,
    c: Feed<()>,
    // more channels...
    manager: Manager,
}

impl Anchor for MyAnchor {
    fn manager(&self) -> &Manager {
        &self.manager
    }
}

Required methods

fn manager(&self) -> &Manager

Get the Manager of this anchor.

Loading content...

Provided methods

fn subscribe<R, T, F>(&mut self, create: F) -> Rc<RefCell<T>> where
    T: Node<Self, R>,
    F: FnOnce(R) -> T, 

Add a node to this anchor.

Uses Node::register_listens to figure out which slots to attach to. Node::register_emits is used to construct a struct that is given to create.

fn unsubscribe<T, R>(&mut self, input: &Rc<RefCell<T>>) where
    T: Node<Self, R>, 

Remove a node from this anchor.

Uses Node::register_listens to figure out which slots to detach from.

Loading content...

Implementors

Loading content...