Re:Show HN: A tiny and fast reactive observables library via...
by leeoniya on Sunday June 26, 2022 @11:21AM
(#31884796)
why not $a(20) and $a(prev => prev + 10)?
[ Parent
| on HN ]
Re:Show HN: A tiny and fast reactive observables library via...
by fabiospampinato on Sunday June 26, 2022 @11:34AM
(#31884908)
It may be as a safety measure, it's much less likely to misuse the setter if it's divided into two different functions. If it's just one function you need to constantly ask yourself "wait, am I setting a function or not?", unless you always want to write `$a(() => value)`, which would be pretty ugly.
Re:Show HN: A tiny and fast reactive observables library via...
by rahim_alwer on Sunday June 26, 2022 @08:31PM
(#31889405)
I started with that but then I thought about what if a callback or some other function is stored as an observable (i.e., like `useCallback`). Also, as fabiospampinato mentioned it's a cleaner seperation of get/set which makes it much easier to differentiate at a quick glace. You can't easily mess it up. I'm still debating whether to achieve what you're after. Maybe I have something mentally twisted and it's easier than I think.