You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the for loop is complete, more pending signals could exist. Instead of only checking watcher.getPending() once, I've opted to check again and again until it's empty.
What are your opinions of this usage pattern? Is it sane?
The text was updated successfully, but these errors were encountered:
Do you, perchance, happen to have a stackblitz or some oss code somewhere with your web components (or a reproduction somewhere)?
there are some unknowns I have about the details of how the components are interacting, and I feel like it'd be helpful to see their code -- and maybe even add them as tests in signal-utils' test suite! 💪
(or would you be willing to submit a PR that only adds tests that re-create your scenario?)
Hi, and thanks for maintaining this library of utilities! It's been really helpful for learning about how the Signals spec works.
Perhaps what I'm doing is an anti-pattern, but I have found it useful to wire signals together like so:
My actual usecase has a few more moving pieces but essentially boils down to the above.
It involves Web Components that pass data to each other via HTML attributes:
Each Web Component manages its internal state using signals. So,
<my-counter>
, has a signal calledcount
.Each Web Component can also take in attributes, which are converted to signals. So,
<my-pretty-text>
has a signal calledtext
.In this example,
<my-counter>
ends up rendering<my-pretty-text>
, passing in the currentcount
in thetext
attribute.So, these HTML attributes present a boundary that prevents me from wiring the two signals together with
Signal.Computed
.What I've noticed about
effect()
andbatchedEffect()
is that they don't always all fire, especially if I set signals in "upstream" effects.For example, in:
signal-utils/src/subtle/microtask-effect.ts
Line 19 in d416b3b
When the
for
loop is complete, more pending signals could exist. Instead of only checkingwatcher.getPending()
once, I've opted to check again and again until it's empty.What are your opinions of this usage pattern? Is it sane?
The text was updated successfully, but these errors were encountered: