Poor man's signals – tiny vanilla JavaScript signals implementation
plainvanillaweb.com
plainvanillaweb.com
Firefox on Android
Update: found it, it was a bug caused by ublock origin. Should be fixed now.
Our own take on this is https://github.com/okcontract/cells where we try to stick as close as possible to the spreadsheet analogy. We're using it to build a very complex web app and it's doing marvels.
But this pales in comparison to the world's most successful FRP application, the spreadsheet.
If you simplify out the event stream primitive from FRP, what you are left with is not FRP.
There were enough true FRP libraries around not to implement another one. We think cells is a sweet spot where we get most of the benefits of functional programming and reactive programming while simplifying the concepts from the original paper from Elliott and Hudak.
One of the best FRP environment for JavaScript is/was FlapJax: https://en.m.wikipedia.org/wiki/Flapjax, which incorporates both the primitives and their operations.
I found https://dev.to/ryansolid/building-a-reactive-library-from-sc... to be a much better ‘from scratch’ example. This is by the maker of SolidJS
It has `computed` too which works very similarly. On top of that, it has integrations with front-end frameworks such as React.
If you want to look a bit deeper into this I had written another sort of toy implementation that much more closely resembles what the frameworks are actually doing: https://github.com/fabiospampinato/flimsy
I think the code itself is messy and outdated ES5, so I rewrote it in TypeScript and made some improvements to QOL, clarity and performance and use that package liberally across a lot of codebases. I'll post it here sometime whenever I push it to GitHub.
The rest of the stuff the article mentions like rerendering and DOM diffing are all extremely inefficient framework nonsense that is entirely unnecessary.
So, to achieve the desired result be event oriented in everything you do, keep things simple, and don’t let framework nonsense distract from common sense.
> [blank box]
Okay, very cool
Rich man’s signals provide a really interesting way to structure incremental computation, sometimes called “self-adjusting computation”, without manual book-keeping elbow-grease from the programmer. Ideally, one can use signals as containers for the inputs to your program and receive a program that automatically does the minimal possible re-computation when a signal changes.
Without that, “poor man’s signals” is just “stores” from React’s 2014 era.