3 ms·
Ok, the EventTarget is a very cute trick and I haven't thought much about implementing signals this way. However, all "serious" signal libraries have at least c
by FjordWarden 2y ago
Ok, the EventTarget is a very cute trick and I haven't thought much about implementing signals this way.
However, all "serious" signal libraries have at least computed (higher order signals), and a way to sample a value, meaning get the value from a signal without triggering its effects, and no you can't just call foo.value because this won't work with computed signals, and a way to batch multiple write calls to multiple signals, which is often implemented by swapping the effects in and out of the update phase of the signal.
- bollu 2y agoCan you elaborate on the batching part for me? I don’t see it
- FjordWarden 2y agoLook: https://github.com/WebReflection/signal/blob/main/esm/index.js#L89 https://github.com/WebReflection/signal/blob/main/esm/index....
- FjordWarden 2y agoAlso, you probably need a root to place signals and effects in a separate scope that can be isolated from the rest of the signal tree and disposed manually, for you know when you have a SPA with multiple pages and tables and you want to be able to update those tables and reorder them and go back and forward in your browser history without it leaking memory like the Titanic. I am struggling to do this myself so not saying I have all the answers here.