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
I think you need to re-assign value to trigger a signal, otherwise you are just updating its internal state without communicating any change happened at all?
it seems that it switches button text to "loading", but it doesnt trigger back.
Updated the @click to simulate waiting time.
(also there was a typo on the example. fixed bellow)
classItem{
#data =signal({});constructor(sData){this.#data.value=sData;}cartLoading(state=false){if(this.#data.value.loading_cart!==state){this.#data.value.loading_cart=statethis.#data.value={...this.#data.value}}returnthis;}renderItem(){returnhtml`<li>${this.#data.value.name}<button@click="${e=>{this.cartLoading(true)setTimeout(()=>{this.cartLoading(false)// <-- this does not trigger the refresh again},2000)}}">${this.#data.value.loading_cart ? 'loading' : 'to cart'}</button></li>`;}}
what if you remove if(this.#data.value.loading_cart !== state) ?
there are various versions of signals in uhtml so if you are anyhow stuck try other variants with preact signals, as example, and let me know if that solves ... if it does, it's my own signal implementation (a different repo) that is doing something weird, if it doesn't, it's your signals based logic that is doing something weird ... I am exploring a rewrite of this library that is currently focused on other topics so my time is limited for this issue but I'd love to understand where, how, this doesn't work, as long as the underlying logic is sound, thanks for your comprehension
Activity
WebReflection commentedon Oct 29, 2024
I think you need to re-assign
valueto trigger a signal, otherwise you are just updating its internal state without communicating any change happened at all?Signals need to notify their value, what's inside their value is never observed ... would that work?
WebReflection commentedon Oct 29, 2024
P.S. if that doesn't work due meomized value, try:
assuming that
data.valueis just, indeed, data and nothing else ... pass a new thingy otherwise with new values.m-michalis commentedon Oct 29, 2024
it seems that it switches button text to "loading", but it doesnt trigger back.
Updated the
@clickto simulate waiting time.(also there was a typo on the example. fixed bellow)
WebReflection commentedon Oct 29, 2024
what if you remove
if(this.#data.value.loading_cart !== state)?there are various versions of signals in uhtml so if you are anyhow stuck try other variants with preact signals, as example, and let me know if that solves ... if it does, it's my own signal implementation (a different repo) that is doing something weird, if it doesn't, it's your signals based logic that is doing something weird ... I am exploring a rewrite of this library that is currently focused on other topics so my time is limited for this issue but I'd love to understand where, how, this doesn't work, as long as the underlying logic is sound, thanks for your comprehension