rx.onValue(v=> { // Get notified when proxy is changed });
// Get and set properties as usual console.log(proxy.x); proxy.x = 20; // Triggers Reactive
Keep in mind that changing target directly won't affect the proxied object or Reactive. Thus,
only update the proxied object after calling fromProxy.
The benefit of objectProxy instead of Rx.From.object is because the proxied object can be passed to other code that doesn't need
to know anything about Reactive objects.
You can assign the return values to more meaningful names using
JS syntax.
If target is an array, it's not possible to change the shape of the array by adding or removing
elements, only by updating existing ones. This follows the same behaviour of objects. Alternatively, use arrayProxy.
See also:
objectProxySymbol: Instead of {proxy,rx} return result, puts the rx under a symbol on the proxy.
arrayProxy: Proxy an array, allowing inserts and deletes.
Creates a proxy of
target
object (or array), so that regular property setting will be intercepted and output on a Reactive object as well.Keep in mind that changing
target
directly won't affect the proxied object or Reactive. Thus, only update the proxied object after callingfromProxy
.The benefit of
objectProxy
instead of Rx.From.object is because the proxied object can be passed to other code that doesn't need to know anything about Reactive objects.You can assign the return values to more meaningful names using JS syntax.
If
target
is an array, it's not possible to change the shape of the array by adding or removing elements, only by updating existing ones. This follows the same behaviour of objects. Alternatively, use arrayProxy.See also:
rx
under a symbol on the proxy.