isComputingMemo
Says whether a memo (not an effect) is computing right now: writing signals is a mistake there.
Says whether a memo (not an effect) is computing right now: writing signals is a mistake there.
Cleanups that run while a memo tears down rows or children may write, so a disposal in progress
is not a violation, and neither is a memo created with allowWrites. Use it to guard a custom
write path the way writeSignal does.
Import#
ts
import { isComputingMemo } from "@shadow-js/core/extend";
Signature#
ts
function isComputingMemo(): boolean
Returns#
true while a memo without allowWrites computes and no disposal is running.
Examples#
ts
import { isComputingMemo, ShadowError } from "@shadow-js/core/extend";
function appendLog(log: string[], entry: string): void {
if (isComputingMemo()) throw new ShadowError("WRITE_IN_MEMO");
log.push(entry);
}