Creates a Reactive wrapper with the shape of the input object.
Changing the wrapped object directly does not update the Reactive. Instead, to update values use:
set()
update()
Consider using Rx.From.objectProxy to return a object with properties that can be set in the usual way yet is also Reactive.
const o = Rx.From.object({ name: `bob`, level: 2 });o.onValue(changed => {});o.set({ name: `mary`, level: 3 });// `onValue` will get called, with `changed` having a value of:// { name: `mary`, level: 3 } Copy
const o = Rx.From.object({ name: `bob`, level: 2 });o.onValue(changed => {});o.set({ name: `mary`, level: 3 });// `onValue` will get called, with `changed` having a value of:// { name: `mary`, level: 3 }
Use last() to get the most recently set value.
last()
onDiff subscribes to a rough diff of the object.
onDiff
const o = Rx.From.object({ name: `bob`, level: 2 });o.onDiff(diffValue => { const diff = diffValue.value;})o.set({ name: `mary`, level: 3 });// onDiff would fire with `diff` of:[ { path: `name`, previous: `bob`, value: `mary` }, { path: `level`, previous: 2, value: 3 }] Copy
const o = Rx.From.object({ name: `bob`, level: 2 });o.onDiff(diffValue => { const diff = diffValue.value;})o.set({ name: `mary`, level: 3 });// onDiff would fire with `diff` of:[ { path: `name`, previous: `bob`, value: `mary` }, { path: `level`, previous: 2, value: 3 }]
You can also listen to updates on a field via onField.
onField
o.onField(`name`, value => { // Called whenever the 'name' field is updated}); Copy
o.onField(`name`, value => { // Called whenever the 'name' field is updated});
Initial value
Options
Optional
Creates a Reactive wrapper with the shape of the input object.
Changing the wrapped object directly does not update the Reactive. Instead, to update values use:
set()
, 'resets' the whole objectupdate()
changes a particular fieldConsider using Rx.From.objectProxy to return a object with properties that can be set in the usual way yet is also Reactive.
Use
last()
to get the most recently set value.onDiff
subscribes to a rough diff of the object.You can also listen to updates on a field via
onField
.Param: initialValue
Initial value
Param: options
Options
Returns