Anatomy
Type Rx.Reactive is the base type of reactives, with this signature:
Consuming
For the most part, you’ll use onValue
to listen for data emitted by the reactive. If you use on
, you’ll get the data and also signalling messages, for example when the reactive completes or there’s an error.
Unsubscribing
Both on
and onValue
return type Unsubscriber
, a function to call to remove the subscription. Use this when you want to keep the source alive, but no longer want to receive values.
Setting values
Only Type Rx.ReactiveWritable reactives support the set
function. This allows you to set a value to the stream, which is then emitted at the on
and onValue
events.
Some types of reactives provide bespoke functions for changing values. For example when using Rx.From.object
, you get an updateField
function for changing the value of a named field.