Aberdeen - v1.0.3
    Preparing search index...

    Function unproxy

    • 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

      • T

        The type of the target.

      Parameters

      • target: T

        A proxied object, array, or any other value.

      Returns T

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

      const userProxy = proxy({ name: 'Frank' });
      const rawUser = unproxy(userProxy);

      // Log reactively
      $(() => console.log('proxied', userProxy.name));
      // The following will only ever log once, as we're not subscribing to any observable
      $(() => console.log('unproxied', rawUser.name));

      // This cause the first log to run again:
      setTimeout(() => userProxy.name += '!', 1000);

      // This doesn't cause any new logs:
      setTimeout(() => rawUser.name += '?', 2000);

      // Both userProxy and rawUser end up as `{name: 'Frank!?'}`
      setTimeout(() => {
      console.log('final proxied', userProxy)
      console.log('final unproxied', rawUser)
      }, 3000);