Show HN: A tiny and fast reactive observables library via functions
1–10 of 41 posts
Re: Show HN: A tiny and fast reactive observables library via functions
#2Re: Show HN: A tiny and fast reactive observables library via functions
#3Hey everyone! I put together a functional reactivity library that uses observable functions as it's primitive for tracking state and changes. It's super tiny (850B), fast, only re-computes the dirty parts of a computation tree, batches updates via a scheduler on to the microtask queue, and works in both browsers and Node. Love any feedback :)
$a(); // read
$a.set(20); // write (1)
$a.update((prev) => prev + 10); // write
why not $a(20) and $a(prev => prev + 10)?Re: Show HN: A tiny and fast reactive observables library via functions
#4Does it handle subscribing to individual values in a collection, or adding/removing values?
Re: Show HN: A tiny and fast reactive observables library via functions
#5- I like that the effect function returns a disposer.
- I don't entirely understand what it means to dispose of observables, is that just an internal optimization for cleanups basically? Exposing an API for this feels a bit risky, like it feels easy to misuse.
- Batching everything feels interesting, no "am I in a batch or not?" problems anymore, though I quite like when things are just executed immediately, I personally prefer to opt into batching only sparingly and for performance reasons.
- A function for creating roots seems missing, I think that's important.
- "isComputed" feels like a weird function to have, maybe it should be called isReadonly since there's a readonly function too and that's what the computed gives you basically? Also maybe there should be an "isObservable" function too?
I've made something similar myself, also inspired by Solid and Sinuous, it started as a fork of Sinuous' observable actually: (https://github.com/vobyjs/oby).
Re: Show HN: A tiny and fast reactive observables library via functions
#6Hey everyone! I put together a functional reactivity library that uses observable functions as it's primitive for tracking state and changes. It's super tiny (850B), fast, only re-computes the dirty parts of a computation tree, batches updates via a scheduler on to the microtask queue, and works in both browsers and Node. Love any feedback :)
$a(); // read $a.set(20); // write (1) $a.update((prev) => prev + 10); // write why not $a(20) and $a(prev => prev + 10)?
Re: Show HN: A tiny and fast reactive observables library via functions
#7Hey everyone! I put together a functional reactivity library that uses observable functions as it's primitive for tracking state and changes. It's super tiny (850B), fast, only re-computes the dirty parts of a computation tree, batches updates via a scheduler on to the microtask queue, and works in both browsers and Node. Love any feedback :)
[0]: https://codesandbox.io/s/oby-bench-cellx-s6kusj?file=/lib.js
Re: Show HN: A tiny and fast reactive observables library via functions
#8Hey everyone! I put together a functional reactivity library that uses observable functions as it's primitive for tracking state and changes. It's super tiny (850B), fast, only re-computes the dirty parts of a computation tree, batches updates via a scheduler on to the microtask queue, and works in both browsers and Node. Love any feedback :)
$a(); // read $a.set(20); // write (1) $a.update((prev) => prev + 10); // write why not $a(20) and $a(prev => prev + 10)?
Re: Show HN: A tiny and fast reactive observables library via functions
#9Re: Show HN: A tiny and fast reactive observables library via functions
#10One critique is "light/tiny/lightweight" whenever I read about software being "light" I cringe and get an eye-twitch(ok not really). But adding "light" or claiming your product is "light" means usually nothing other than its new.
Sure it might start out as small/lightweight but usually this is because the software is new.
Once you start adding in corner-cases (the ones you haven't even thought about) some iterations of bug fixes (hey we all human programmers in the end), mix in a good dose of pull-request from helpful contributors (User:'Your library looks great, if you accept this PR it will fit my needs perfectly.') and finally bring it up to par with a competitor of two (over time of course !).
Your now light software is no longer light !
What is the answer ? To be honest I don't have one, but to say knucckle down and be sure to say no often enough and have a laser focus on the exact problem your software is solving. Of course it seldom the case in real life with real software :)
Anywhoo ! Congrats on actually releasing something :)