Skip to content

reactive()

Okku edited this page May 31, 2021 · 3 revisions

The reactive method takes values of any type and converts them into reactive ones:

  • If the value is an array, it gets converted into a ReactiveArray.
  • If the value is a Promise, it gets converted into a ReactivePrimitive that updates once the Promise resolves. Takes an optional fallback property in the optional options object as the second argument.
  • If the value is a non-function object, it gets passed to reactiveObject().
  • Otherwise the value gets converted to a ReactivePrimitive.

The second argument is an optional options object:

  • options.fallback? A fallback value to be displayed when the initial value is a pending Promise.
  • options.parent? Another reactive object to whom any reactive items created should report to when updating, so updates can correctly propagate to the highest level. You will most likely not need to ever set this option manually unless you're making custom extensioins.

← Previous: §1.3 reactiveObject() | Next: §1.5 computed()