TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Managing State with Signals

208 pointsby geospeckabout 2 years ago

16 comments

mpweiherabout 2 years ago
It looks like we are going to keep reinventing dataflow constraints[1] over and over again, always with slightly different terminology (Rx, FRP, signals, ...)<p>So it (a) appears to be a very useful or at least attractive concept, and (b) somehow difficult to fit into current programming languages&#x2F;practice in a clean way.<p>[1] <a href="https:&#x2F;&#x2F;blog.metaobject.com&#x2F;2014&#x2F;03&#x2F;the-siren-call-of-kvo-and-cocoa-bindings.html" rel="nofollow">https:&#x2F;&#x2F;blog.metaobject.com&#x2F;2014&#x2F;03&#x2F;the-siren-call-of-kvo-an...</a> (HN: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7404149" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7404149</a> )
评论 #35999613 未加载
评论 #36000662 未加载
评论 #35999537 未加载
评论 #35999189 未加载
samsquireabout 2 years ago
It&#x27;s interesting how every build system, frontend framework, programming language implements its own promise pipeline&#x2F;delayed execution&#x2F;observables&#x2F;event propagation.<p>But the implementations are rarely extracted out for general purpose usage and rarely have a rich API.<p>I&#x27;ve been thinking a lot about a general purpose &quot;epoll&quot; which be registered on objects that change. I want to be able to register a reaction to a sequence of actions on arbitrary objects with an epoll style API.<p>One of my ideas is GUI thunking. The idea that every interaction with the GUI raises a new type that can be interacted with, to queue up behaviours on the GUI. This is essentially Future&lt;&gt; that are typed and the system reacts to the new type based on what you did and presents a GUI that is as if the operation you queued up was completed. (You can interact with the future because any action on something that isn&#x27;t done yet, is queued up)<p>It&#x27;s a bit like terraform plan and apply, but applied to general purpose GUIs.<p>For example, you can click download file, then queue up installation and then using the application, ALL BEFORE it is installed. Because the actual computation is separate from the type information that was queued up.<p>Imagine using AWS Console to set up an entire infrastructure and wire everything together but not actually execute anything until the very end when you click &quot;Run&quot;.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;gui-thunks">https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;gui-thunks</a><p>I feel we are still early days with regard how to build computer user interfaces that are easy to build, maintain and understand the code for.<p>I used knockout and angularjs 1 and I enjoyed Knockout especially. ko.observables and the map plugin makes creating reactive code very straightforward.
评论 #35999010 未加载
评论 #35999334 未加载
评论 #36102829 未加载
评论 #35999341 未加载
评论 #36006996 未加载
评论 #35998972 未加载
评论 #35999964 未加载
评论 #36001842 未加载
评论 #36006649 未加载
评论 #35999265 未加载
naaskingabout 2 years ago
Not sure I like the mixed push&#x2F;pull approach. If you&#x27;re already traversing the tree to mark nodes as possibly dirty, you might as well recompute the node&#x27;s value and store it while you&#x27;re there. Otherwise on pull&#x2F;lazy update, you&#x27;re traversing the tree all over again! Terrible for cache locality, particularly for large graphs.<p>You might be tempted to say that the lazy approach might avoid some recomputations, but if a node isn&#x27;t actually going to be accessed then that node is effectively no longer live and should be disposed of&#x2F;garbage collected, and so it will no longer be in the update path anyway!<p>The mixed push&#x2F;pull approach has only once nice property: it avoids &quot;glitches&quot; when updating values that have complex dependencies. The pull-based evaluation implicitly encodes the correct dependency path, but a naive push-based approach can update some nodes multiple times in non-dependency order. Thus a node can take on multiple incorrect values while a reaction is ongoing, only eventually settling on the correct value once the reaction is complete.<p>In other push-based reactive approaches, you have to explicitly schedule the updates in dependency order to avoid such glitches, so perhaps this push&#x2F;pull approach was picked to keep things simple.
评论 #36002314 未加载
评论 #36006737 未加载
评论 #36006291 未加载
评论 #36003347 未加载
Bogdanpabout 2 years ago
I took a similar approach in my Racket library, gui-easy[1,2]. Though I opted to not defer any computations. Any observable (similar to a signal from the post) update propagates to observers immediately, and there&#x27;s no incrementality -- observables are just boxes whose changes you can subscribe to. Regarding the disposal problem, I used weak references and regarding the where to take observables and where to take concrete values as input question, I decided that any place an observable can go in, a concrete value can as well and it&#x27;s been a convenient choice so far. For fun, here&#x27;s an example[3] that builds the todo UI from the post.<p>[1]: <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;gui-easy&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;gui-easy&#x2F;index.html</a><p>[2]: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=7uGJJmjcxzY">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=7uGJJmjcxzY</a><p>[3]: <a href="https:&#x2F;&#x2F;github.com&#x2F;Bogdanp&#x2F;racket-gui-easy&#x2F;blob&#x2F;364e8becaafaab739c740a877cbdefed363a32b9&#x2F;examples&#x2F;todo.rkt">https:&#x2F;&#x2F;github.com&#x2F;Bogdanp&#x2F;racket-gui-easy&#x2F;blob&#x2F;364e8becaafa...</a>
pdamocabout 2 years ago
Elm started as a FRP language and ended up giving up FRP[1] for ease of use.<p>If ease of use is targeted, signals might not be the best approach. I distinctly remember things becoming easier when they went away.<p>[1] <a href="https:&#x2F;&#x2F;elm-lang.org&#x2F;news&#x2F;farewell-to-frp" rel="nofollow">https:&#x2F;&#x2F;elm-lang.org&#x2F;news&#x2F;farewell-to-frp</a>
评论 #36002446 未加载
评论 #36000779 未加载
EMM_386about 2 years ago
Topical, because Angular 16 was just released with ... Signals.<p>Used in <i>some</i> places to simplify RxJs or not need it at all. <i>Some</i>, not all.<p>They are looking towards a future where they can get rid of Zone.js and its strategry to change detection. I see this as a step along that part.<p><a href="https:&#x2F;&#x2F;blog.angular.io&#x2F;angular-v16-is-here-4d7a28ec680d" rel="nofollow">https:&#x2F;&#x2F;blog.angular.io&#x2F;angular-v16-is-here-4d7a28ec680d</a>
slevcomabout 2 years ago
The author does a lovely job of covering a number of the interesting ideas in this space. But reactive programming is such a tough sell. I know from experience.<p>I maintain a reactive, state management library that overlaps many of the same ideas discussed in this blog post. <a href="https:&#x2F;&#x2F;github.com&#x2F;yahoo&#x2F;bgjs">https:&#x2F;&#x2F;github.com&#x2F;yahoo&#x2F;bgjs</a><p>There are two things I know to be true:<p>1. Our library does an amazing job of addressing the difficulties that come with complex, interdependent state in interactive software. We use it extensively and daily. I&#x27;m absolutely convinced it would be useful for many people.<p>2. We have completely failed to convince others to even try it, despite a decent amount of effort.<p>Giving someone a quick &quot;here&#x27;s your problem and this is how it solves it&quot; for reactive programming still eludes me. The challenge in selling this style of programming is that it addresses complexity. How do you quickly show someone that? Give them a simple example and they will reasonably wonder why not just do it the easy way they already understand. Give them a complex example and you&#x27;ve lost them.<p>I&#x27;ve read plenty of reactive blog posts and reactive library documentation sets and they all struggle with communicating the benefits.
评论 #36022806 未加载
评论 #36003828 未加载
评论 #36003342 未加载
bradrnabout 2 years ago
The previous article in the series is also a very interesting read: <a href="https:&#x2F;&#x2F;tonsky.me&#x2F;blog&#x2F;humble-state&#x2F;" rel="nofollow">https:&#x2F;&#x2F;tonsky.me&#x2F;blog&#x2F;humble-state&#x2F;</a>
评论 #36007107 未加载
inglorabout 2 years ago
This is what MobX does and so does Vue and a few other frameworks like Solid or Qwik (though with a different rendering model) - hardly a novel idea.<p>Heck even in lisps there was reagent which was basically this and had atoms&#x2F;signals :)
codeulikeabout 2 years ago
That site really shows the best way to do dark mode
评论 #35999453 未加载
评论 #36002003 未加载
dm3about 2 years ago
Interesting that this is Clojure and it doesn&#x27;t mention Hoplon&#x2F;Javelin[0] as prior work. I&#x27;ve used Hoplon&#x2F;UI[1] to implement a moderately complex web app ~6 years ago. The library is practically a prototype, pretty much dead by now. However, I found the ideas interesting.<p>I find the biggest benefit of using a fringe library like this is the ability to read and understand the whole implementation. It&#x27;s really simple compared to something like React.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;hoplon">https:&#x2F;&#x2F;github.com&#x2F;hoplon</a><p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;hoplon&#x2F;ui">https:&#x2F;&#x2F;github.com&#x2F;hoplon&#x2F;ui</a>
评论 #36095856 未加载
评论 #36004163 未加载
lewiscarsonabout 2 years ago
This looks really interesting but the colour scheme makes it impossible to read.
评论 #35999574 未加载
评论 #35998961 未加载
评论 #35999227 未加载
评论 #35999876 未加载
tijssssabout 2 years ago
I&#x27;m working on a project to make bootstrap work without js. Similar state management, check at <a href="https:&#x2F;&#x2F;noojs.pages.dev&#x2F;components&#x2F;accordion.html" rel="nofollow">https:&#x2F;&#x2F;noojs.pages.dev&#x2F;components&#x2F;accordion.html</a> <a href="https:&#x2F;&#x2F;noojs.pages.dev&#x2F;components&#x2F;modal.html" rel="nofollow">https:&#x2F;&#x2F;noojs.pages.dev&#x2F;components&#x2F;modal.html</a>
itronitronabout 2 years ago
This article would be more compelling if the demo videos showed a UI that actually worked. I&#x27;m left wondering if their day job is building consent dialogs for websites.
评论 #36004195 未加载
KRAKRISMOTTabout 2 years ago
The observable syntax is confusing. Lisp uses *earmuffs* syntax for global variables, if you only use one muff for an observable variable, how would you express a global variable that&#x27;s observable? Using **lopsided muffs*?
评论 #36002127 未加载
评论 #36004208 未加载
SergeAxabout 2 years ago
Designer of this theme shoud be stabbed with a keyboard.
评论 #36006797 未加载