futures_rx/
subject.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pub mod behavior_subject;
pub mod publish_subject;
pub mod replay_subject;
pub mod shareable_subject;

use std::{cell::RefCell, rc::Rc};

use crate::{Controller, Event, Observable};

type Subscription<T> = Rc<RefCell<Controller<Event<T>>>>;

pub trait Subject {
    type Item;

    fn subscribe(&mut self) -> Observable<Self::Item>;
    fn close(&mut self);
    fn next(&mut self, value: Self::Item);
    fn for_each_subscription<F: FnMut(&mut Subscription<Self::Item>)>(&mut self, f: F);
}