| Nice! I love these tiny libraries. Some random thoughts: - 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). |
In MobX there are various things that have to be manually cleaned up at different times to avoid memory-leaks, since reactive systems like this involve a lot of cross-references. I could imagine eg. that cleaning up an observable in this library releases references to all memoized values that were derived from it