peek
Call Signature
Section titled “Call Signature”peek<
T,K>(target,key):T[K]
Defined in: aberdeen.ts:3246
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 A) 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
Section titled “Type Parameters”T extends object
K extends string | number | symbol
Parameters
Section titled “Parameters”target
Section titled “target”T
Either a function to execute, or an object (which may also be an Array or a Map) to index.
K
Optional key/index to use when target is an object.
Returns
Section titled “Returns”T[K]
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.
Example
Section titled “Example”Peeking within observer
const $data = A.proxy({ a: 1, b: 2 });A(() => { // re-executes only when $data.a changes, because $data.b is peeked. const b = A.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.")Call Signature
Section titled “Call Signature”peek<
K,V>(target,key):V
Defined in: aberdeen.ts:3247
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 A) 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
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”target
Section titled “target”Map<K, V>
Either a function to execute, or an object (which may also be an Array or a Map) to index.
K
Optional key/index to use when target is an object.
Returns
Section titled “Returns”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.
Example
Section titled “Example”Peeking within observer
const $data = A.proxy({ a: 1, b: 2 });A(() => { // re-executes only when $data.a changes, because $data.b is peeked. const b = A.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.")Call Signature
Section titled “Call Signature”peek<
T>(target,key):T
Defined in: aberdeen.ts:3248
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 A) 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
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”target
Section titled “target”T[]
Either a function to execute, or an object (which may also be an Array or a Map) to index.
number
Optional key/index to use when target is an object.
Returns
Section titled “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.
Example
Section titled “Example”Peeking within observer
const $data = A.proxy({ a: 1, b: 2 });A(() => { // re-executes only when $data.a changes, because $data.b is peeked. const b = A.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.")Call Signature
Section titled “Call Signature”peek<
T>(target):T
Defined in: aberdeen.ts:3249
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 A) 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
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”target
Section titled “target”() => T
Either a function to execute, or an object (which may also be an Array or a Map) to index.
Returns
Section titled “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.
Example
Section titled “Example”Peeking within observer
const $data = A.proxy({ a: 1, b: 2 });A(() => { // re-executes only when $data.a changes, because $data.b is peeked. const b = A.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.")