Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

observable_create

crates.io ci codecov license

The create_observable provides a simple way to create custom observables by defining a producer function that can emit values to subscribers.

The producer function is cloned for each subscribe call to avoid shared state between individual subscriptions.

See Also

Example

cargo run -p rx_core --example observable_create_example
let _s = create_observable::<&str, Never, _>(|destination| {
    destination.next("hello");
    destination.complete();
})
.subscribe(PrintObserver::new("create_observable"));
create_observable - next: "hello"
create_observable - completed
create_observable - unsubscribed