unproxy
unproxy<
T>(target):T
Defined in: aberdeen.ts:1965
Returns the original, underlying data target from a reactive proxy created by proxy.
If the input target is not a proxy, it is returned directly.
This is useful when you want to avoid triggering subscriptions during read operations or re-executes during write operations. Using peek is an alternative way to achieve this.
Type Parameters
Section titled “Type Parameters”T
The type of the target.
Parameters
Section titled “Parameters”target
Section titled “target”T
A proxied object, array, or any other value.
Returns
Section titled “Returns”T
The underlying (unproxied) data, or the input value if it wasn’t a proxy.
Example
Section titled “Example”const $user = A.proxy({ name: 'Frank' });const rawUser = A.unproxy($user);
// Log reactivelyA(() => console.log('proxied', $user.name));// The following will only ever log once, as we're not subscribing to any observableA(() => console.log('unproxied', rawUser.name));
// This cause the first log to run again:setTimeout(() => $user.name += '!', 1000);
// This doesn't cause any new logs:setTimeout(() => rawUser.name += '?', 2000);
// Both $user and rawUser end up as `{name: 'Frank!?'}`setTimeout(() => { console.log('final proxied', $user) console.log('final unproxied', rawUser)}, 3000);