-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Background
Some Signal frameworks, like Preact and many others, allow you to "dispose" of a computed of effect.
Once they are disposed, they will no longer be reevaluated.
Possible syntax
One possible syntax is to return the dispose
function as part of the computed or effect object:
const computed = $computed(fn);
// then it can be disposed as follows
computed.dispose();
Or the function can be destructured out of the object
const {dispose} = $computed(fn);
You should be able to check if a value is disposed
const isDisposed = computed.disposed
Reacting to a disposal
We can allow for a function to be assigned that will run when a computed or effect get disposed.
const computed = $computed(fn);
computed.onDispose(() => console.log('the computed was disposed'));
Further investigation necessary
What happens to the computed and effects that depend on the disposed value when a computed
signal gets disposed?
Ideas:
- We can freeze the last value of the computed. When a dependency changes a disposed computed will not be recomputed, but dependants will still have a reference to the last value.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request