Aberdeen - v1.1.0
    Preparing search index...

    Function peek

    • Executes a function or retrieves a value without creating subscriptions in the current reactive scope, and returns its result.

      This is useful when you need to access reactive data inside a reactive scope (like $) but do not want changes to that specific data to trigger a re-execute of the scope.

      Note: You may also use unproxy to get to the raw underlying data structure, which can be used to similar effect.

      Type Parameters

      • T extends object

      Parameters

      • target: T

        Either a function to execute, or an object (which may also be an Array or a Map) to index.

      • key: keyof T

        Optional key/index to use when target is an object.

      Returns T[keyof T]

      The result of the function call, or the value at target[key] when target is an object or target.get(key) when it's a Map.

      const data = proxy({ a: 1, b: 2 });
      $(() => {
      // re-executes only when data.a changes, because data.b is peeked.
      const b = peek(() => data.b);
      console.log(`A is ${data.a}, B was ${b} when A changed.`);
      });
      data.b = 3; // Does not trigger console.log
      data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
    • Executes a function or retrieves a value without creating subscriptions in the current reactive scope, and returns its result.

      This is useful when you need to access reactive data inside a reactive scope (like $) but do not want changes to that specific data to trigger a re-execute of the scope.

      Note: You may also use unproxy to get to the raw underlying data structure, which can be used to similar effect.

      Type Parameters

      • K
      • V

      Parameters

      • target: Map<K, V>

        Either a function to execute, or an object (which may also be an Array or a Map) to index.

      • key: K

        Optional key/index to use when target is an object.

      Returns undefined | V

      The result of the function call, or the value at target[key] when target is an object or target.get(key) when it's a Map.

      const data = proxy({ a: 1, b: 2 });
      $(() => {
      // re-executes only when data.a changes, because data.b is peeked.
      const b = peek(() => data.b);
      console.log(`A is ${data.a}, B was ${b} when A changed.`);
      });
      data.b = 3; // Does not trigger console.log
      data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
    • Executes a function or retrieves a value without creating subscriptions in the current reactive scope, and returns its result.

      This is useful when you need to access reactive data inside a reactive scope (like $) but do not want changes to that specific data to trigger a re-execute of the scope.

      Note: You may also use unproxy to get to the raw underlying data structure, which can be used to similar effect.

      Type Parameters

      • T

      Parameters

      • target: T[]

        Either a function to execute, or an object (which may also be an Array or a Map) to index.

      • key: number

        Optional key/index to use when target is an object.

      Returns undefined | T

      The result of the function call, or the value at target[key] when target is an object or target.get(key) when it's a Map.

      const data = proxy({ a: 1, b: 2 });
      $(() => {
      // re-executes only when data.a changes, because data.b is peeked.
      const b = peek(() => data.b);
      console.log(`A is ${data.a}, B was ${b} when A changed.`);
      });
      data.b = 3; // Does not trigger console.log
      data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
    • Executes a function or retrieves a value without creating subscriptions in the current reactive scope, and returns its result.

      This is useful when you need to access reactive data inside a reactive scope (like $) but do not want changes to that specific data to trigger a re-execute of the scope.

      Note: You may also use unproxy to get to the raw underlying data structure, which can be used to similar effect.

      Type Parameters

      • T

      Parameters

      • target: () => T

        Either a function to execute, or an object (which may also be an Array or a Map) to index.

      Returns T

      The result of the function call, or the value at target[key] when target is an object or target.get(key) when it's a Map.

      const data = proxy({ a: 1, b: 2 });
      $(() => {
      // re-executes only when data.a changes, because data.b is peeked.
      const b = peek(() => data.b);
      console.log(`A is ${data.a}, B was ${b} when A changed.`);
      });
      data.b = 3; // Does not trigger console.log
      data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")