DEV Community

Discussion on: React vs Signals: 10 Years Later

Collapse
 
drsensor profile image
૮༼⚆︿⚆༽つ

Just imagining the future, I think the next step of signal would be Atomic Signal where it can propagate effects across worker/thread 🤔 (akin to Go channel + reactive variable)

Collapse
 
davedbase profile image
David Di Biase

Hah! I started working on this. The question ultimately is: why would it be valuable in JS? The cost of sending between worker/thread in the browser isn't worth it.

Collapse
 
drsensor profile image
૮༼⚆︿⚆༽つ • Edited

Not if you use SharedArrayBuffer and model every instance of reactive variable as StructOfArray. The crazy part is on when to use the mutex guard 😂

Atomic Signal is very valuable on apps/games that utilize OffscreenCanvas. Writing both heavy rendering and logic off-main-thread is a deal breaker.

Thread Thread
 
vincentvandijck profile image
bigmistqke

Yes! I have been thinking about this a lot lately... I feel it should be possible with .notify and .wait.

Good inspiration: javascript.plainenglish.io/buildin... they use a SharedArrayBuffer with atomics only for updating indices to update a float arraybuffer.

Thread Thread
 
vincentvandijck profile image
bigmistqke

Oo waw github.com/Bnaya/objectbuffer this project is so so crazy. A proxy implementation of an object w (shared)arraybuffer under the hood. Serializes the schema somehow in the arraybuffer... Wild stuff.

Someone please slap reactivity on top of this plz.

Thread Thread
 
vincentvandijck profile image
bigmistqke
Thread Thread
 
drsensor profile image
૮༼⚆︿⚆༽つ

Oo waw github.com/Bnaya/objectbuffer this project is so so crazy. A proxy implementation of an object w (shared)arraybuffer under the hood. Serializes the schema somehow in the arraybuffer... Wild stuff.

Wait, Struct of Array backed by virtual memory (SharedArrayBuffer)!? That's wild!

Thread Thread
 
drsensor profile image
૮༼⚆︿⚆༽つ • Edited

I think I've done something similar but it just something on a whim for creative coding. (not yet using futex like Aomics.waitAsync and Atomics.notify)

fosstodon.org/@drsensor/1093552594...

Collapse
 
peerreynders profile image
peerreynders

Is called fine-grained reactivity after all and crossing the worker boundaries for fine-grained values is likely not optimal.

However something for more course-grained messages that can feed into fine-grained reactive graphs should work.

Is postMessage slow? (Surma, 2019)

Thread Thread
 
davedbase profile image
David Di Biase

Thanks for sharing this! It reinvigorates my interest in exploring the idea in future :)

Thread Thread
 
peerreynders profile image
peerreynders

If you're interested I have a collection of links here

Thread Thread
 
davedbase profile image
David Di Biase

Thanks!!!