Closed dy closed 8 months ago
In particular I hoped to use it in untracked function to allow sub-effects
const untracked = fn => computed(fn).peek()
without effects around and nobody subscribing via .value
I don't know why you would need a computed instead of a regular fn()
returned value but I've kinda moved to https://github.com/WebReflection/signal when reactivity is minimal and use either preact core or solid signals for more battle-tested solutions, see uhtml/preactive.
I should probably sunset this module as I don't have time, nor care much these days, about it and I won't likely fix anything in the near future.
One use case I just showed. @webreflection/signal has the same issue. Main reason why I wanted to use usignal over preact-signals is the size - it's twice smaller.
Do you have an idea how to make untracked function with usignal? In preact/signals it's exported by default.
If you prefer I can check out the source and propose a PR
PR welcome, I hope the code in ./esm/
folder is eaasy enough to follow, thanks!
@WebReflection do you have any signals implementation that you actually maintain?
@titoBouzout the @webreflection/signal is up-to-date & well-made. Also check out ulive - probably the most minimal signals implementation.
usignal only needs untracked
and effect teardown to be in-sync.
Thanks! @dy one of the issues with all this small signal libraries is that making anything that isn't trivial requires a Context API, if they don't expose an owner, with parents and a runWithOwner it becomes impossible to implement.
Yeah, if you're talking about react/preact I'd suggest @preact/signals or @preact/signals-react is the right way to avoid footguns and wasted time, but to be honest signals don't shine there - they get mixed up with hooks and it becomes a mess. But as a standalone reactive primitive or foundation for a framework they're brilliant.
I do not use react/preact, I come from a solidjs background, see https://pota.quack.uy/
uhtml/preactive and uhtml/signal give you that parent owner if I understood your concern ... as you always need a function to render (when you want nested/confined reactivity) or skip that to render parent on changes within nested components.
@WebReflection please correct me what I do wrong or misunderstand:
sandbox
It doesn't seem to be the case with
@preact/signals-core
.