Skip to content

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.

T

The type of the target.

T

A proxied object, array, or any other value.

T

The underlying (unproxied) data, or the input value if it wasn’t a proxy.

const $user = A.proxy({ name: 'Frank' });
const rawUser = A.unproxy($user);
// Log reactively
A(() => console.log('proxied', $user.name));
// The following will only ever log once, as we're not subscribing to any observable
A(() => 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);