[][src]Trait revent::Subscriber

pub trait Subscriber<A: Anchor> {
    type Emitter: Emit<A>;
    fn register(anchor: &mut A, item: Rc<RefCell<Self>>);
}

Describes a subscriber that can subscribe to Anchor.

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

trait A {}

struct MySlots {
    a: Slot<A>,
    manager: Rc<RefCell<Manager>>,
}

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

// ---

struct MyNode;

impl Subscriber<MySlots> for MyNode {
    type Emitter = ();

    fn register(slots: &mut MySlots, item: Rc<RefCell<Self>>) {
        slots.a.register(item);
    }

}
impl Named for MyNode {
    const NAME: &'static str = "MyNode";
}

impl A for MyNode {}

Associated Types

type Emitter: Emit<A>

The type of the node it uses to further send signals to other Slots.

May be () if no further signals are sent from this subscriber.

Loading content...

Required methods

fn register(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 subscriber may still be subscribed to some channels after unsubscribe has been called.

Loading content...

Implementors

Loading content...