fast icon indicating copy to clipboard operation
fast copied to clipboard

fix: inconsistent observable behavior when used with getter

Open olaf-k opened this issue 1 year ago • 1 comments

🐛 Bug Report

I recently stumbled on a strange behavior where this code works:

${when((x) => x.myObservable && x.myGetter, html(...snip...)

but not this one:

${when((x) => x.myGetter && x.myObservable, html(...snip...)

meaning that only the first example properly reacts when myObservable's value changes.

💻 Repro or Code Sample

https://stackblitz.com/edit/vitejs-vite-davib1?file=src%2Fmain.ts

To elaborate on the scenario: myGetter is updated but should not trigger when (so no need to make it an observable). myObservable is the one whose value should drive the template updates.

🤔 Expected Behavior

Both expressions should result in the same behavior.

💁 Possible Solution

I didn't have time to dig into the observable implementation, sorry. Maybe some kind of memoization is involved?

olaf-k avatar Nov 28 '24 14:11 olaf-k

@olaf-k thanks for filing this, definitely seems like a bug, looking into it!

janechu avatar Dec 05 '24 19:12 janechu