Get the latest tech news

Poor man's signals – tiny vanilla JavaScript signals implementation


Signals are all the rage over in frameworkland, so let's bring them to vanilla JS.

In short, signals are an efficient and targeted way to respond to changes without having to do state comparison and DOM-diffing. The effect(fn) method will call the specified function, and also subscribe it to changes in the signal's value. The full poor man's signals code in all its 36 line glory can be found in the tiny-signals repo on Github.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of javascript

javascript

Photo of signals

signals

Photo of implementation

implementation

Related news:

News photo

Python, JavaScript, Java: ZDNet Calculates The Most Popular Programming Languages

News photo

The Design and Implementation of the CPython Virtual Machine

News photo

Fungus learns to drive in "biohybrid" robots | A new kind of “biohybrid” robot moves in response to signals from the nervous system of a fungus.