Usage
Wrap
You can Rx.wrap a reactive (or raw source) in an object for fluent, chainable function calls.
After calling wrap, you can invoke operators directly, for example:
Sources can be another wrapped reactive, a normal reactive, iterable, generator, array or function that returns a value.
For example:
Rx.wrap
is nice because you get good code-completion and it can be very concise. The downside is that you don’t get access to the individual parts of a flow if they need to be manipulated after creation.
Run
Compose a source and set of operators together with Rx.run . It returns a new reactive emitting the value of the last operator in the list.
Writable
Rx.run will return a reactive that essentially captures the last operator in the list. It doesn’t make sense to write to this reactive since it represents the tail-end.
If you need to be able to write to the head of a composed flow and read the final result, use Rx.writable . Naturally, the source needs to be a writable one.
Fine-grained
Most of the given examples of Rx.run
and Rx.writable
create and compose sources and operators in one go. But we can use sources and operators more directly if needed: