[][src]Trait revent::Anchor

pub trait Anchor where
    Self: Sized
{ fn manager(&self) -> &Rc<RefCell<Manager>>; fn subscribe<T, F>(&mut self, create: F) -> Rc<RefCell<T>>
    where
        T: Named + Subscriber<Self>,
        T::Emitter: for<'a> From<&'a Self>,
        F: FnOnce(T::Emitter) -> T
, { ... }
fn unsubscribe<T>(&mut self, input: &Rc<RefCell<T>>)
    where
        T: Subscriber<Self>
, { ... } }

A collection of Slots and Singles to which Subscribers can subscribe.

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

A typical implementation may look like this:

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

struct MySlots {
    a: Slot<()>,
    b: Slot<()>,
    // more slots...
    manager: Rc<RefCell<Manager>>,
}

impl Anchor for MySlots {
    fn manager(&self) -> &Rc<RefCell<Manager>> {
        &self.manager
    }
}

Required methods

fn manager(&self) -> &Rc<RefCell<Manager>>

Get the Manager of this anchor.

Loading content...

Provided methods

fn subscribe<T, F>(&mut self, create: F) -> Rc<RefCell<T>> where
    T: Named + Subscriber<Self>,
    T::Emitter: for<'a> From<&'a Self>,
    F: FnOnce(T::Emitter) -> T, 

Add a subscriber to this anchor.

Uses Subscriber::register to figure out which slots to attach to.

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

Remove a subscriber from this anchor.

Uses Subscriber::register to figure out which slots to detach from.

Loading content...

Implementors

Loading content...