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.
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.
Either a function to execute, or an object (which may also be an Array or a Map) to index.
Optional key/index to use when target
is an object.
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.
Either a function to execute, or an object (which may also be an Array or a Map) to index.
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.