15 comments

[ 132 ms ] story [ 351 ms ] thread
Preact signals are far superior to other state management patterns for react, but don't use a ContextProvider as shown is this article, pass the signals as props instead.

e.g:

  function MyComponent({ disabled }: { disabled: Signal<boolean> }) {
    // ...
  }
"Traditional state management like React hooks triggers..."

Traditional? I remember when React was the new kid on the block. I am getting old! :-D

I don't like the style of code in the article, with weird functions like "useState" and "useSignal". Looks ugly to me.

Also, it seems that with signals you must use immutable values only. Imagine if you have, let's say, a text document model, and you need to create a new copy every time the user types a letter. That's not going to work fast. And there will be no granular updates, because the signal only tracks the value (whole document), not its components (a single paragraph).

Also the article mentions rarely used preact and doesn't mention Vue. Vue can track mutable object graphs (for example, text document model). But Vue uses JS proxies that have lot of own issues (cannot access private fields, having to deal with mixing proxies and real values when adding them to a set, browser APIs break when a proxy is passed).

Also I don't like that React requires installing Node and compilation tools, this is a waste of time when making a quick prototype. Vue can be used without Node.

Are Angular signals the same as Preact signals?
This article is completely backwards. We do not want to manually manage what-gets-refreshed-when. The whole point of React was to react to state changes automatically.
> Traditional state management like React hooks

Oh boy. The youth of the author is really visible.

(comment deleted)
Relatedly, there is a stage-1 proposal to add first-class signals to Javascript: https://github.com/tc39/proposal-signals

It's a collaboration between multiple library maintainers, attempting to standardize and unify their shared change-tracking approach.

It remains a bit of a mystery to me that applications seem to grow further and further from traditional game techniques. Both in how state is propagated through the application, and in how it is represented.

Like, I understand why people aren't going full 3d game simulation style for applications. But I don't understand why things are as divergent as they are?

Is this just my off perspective?

I recently had to do maintenance on an old WPF app and bring it to .NET9.

I feel like at some point we are gonna complete the cycle and have MVVM/MVC binding engines in frontend dev.

There is barely any difference left between createContext+useSignal vs. C# DataContext+ObservableProperty.

I’ve been a ClojureScript developer for many years, and we (as a community) have had the pleasure of the reagent library. From the early days of react, it was basically a signals-like library with an ergonomic api. Signals are almost a requirement in ClojureScript, assume you want to do any sort of REPL-based workflows.

In the time that I’ve been using ClojureScript, the whole react community has switched to hooks. I find it so baffling - requiring your entire data structure to be contained within your component lifecycle? The thousands of calls to individual “useState” to track the same number of state items? The fact that every function is closing over historical state unless you manually tell it to change every time the variable does — and then this last bit in combination with non-linear deep equality comparisons?

I recently have been in the process of switching phrasing.app from reagent atoms to preact/signals for performance reasons (and as part of a longer horizon move from react to preact) and I have to say it’s been fantastic. Maybe 50 lines of code to replicate reagent atoms with preact/signals, all the benefits, and much much faster.

Very happy that there is react-like library so devoted to first class support of signals.

It's hilarious that the Observable pattern that MVC and Qt are organized around has become "a game-changer for large applications where context is used to distribute state across many components" this year. MVC is maybe 50 years old now?
I started thinking Angular is actually pretty good.
My mind immediately jumped to the recent Chat Control drama after reading the title.

One way I frame such issues in my mind is that it's about who has control (and how much) over what is rendered and when on the screen I carry in my pocket. To some extent it is now Signal when I use the app. One day it might be my State instead.