[−][src]Struct froop::Subscription
A subscription is a receipt for adding a listener to a stream. Can be used to stop listening.
Subscription lifetimes
Every combinator subscribes to events from its parent stream. It is basically the
same as calling .subscribe()
but with an important twist. Froop reference counts
the number of children alive to determine when to unsubscribe.
Example:
use froop::{Sink, Stream}; let sink: Sink<u32> = Stream::sink(); let stream = sink.stream(); // map is subscribed (once) to stream let map = stream.map(|v| v * 2); let map2 = map.clone(); drop(map); drop(map2); // map is unsubscribed from stream
This is different to regular subscriptions where we must explicitly call .unsubscribe()
on the returned subscription instance.
Example:
use froop::{Sink, Stream}; let sink: Sink<u32> = Stream::sink(); let stream = sink.stream(); // subscribed to stream let sub = stream.subscribe(|v| if let Some(v) = v { println!("{}", v) }); drop(sub); // still subscribed to stream
Methods
impl Subscription
[src]
pub fn unsubscribe(&self)
[src]
Stops listening to the stream.
Trait Implementations
impl Clone for Subscription
[src]
fn clone(&self) -> Subscription
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl Send for Subscription
impl Sync for Subscription
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,