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.

Ask HN: Qt style "Signals and Slots" based JavaScript UI library?

6 pointsby tmbsundar30 days ago
Are there any equivalent of Qt style loosely coupled "Signals and Slots" based JavaScript UI library? Qt allows widget/ components to be connected to each other with a pub-sub type of system where the emitter of the signal really need not care who the consumer is. While, IIUC, most JS libraries follow a hierarchically coupled state passing system where sharing of state happens through props/ passing down from parent to child components with lifted state etc., Was wondering if there are any JS libraries which operate in the style of Qt event driven signal-slot connections as a primary paradigm.

4 comments

codemusings29 days ago
I&#x27;m of the opinion that this is bad design because it makes it very hard to reason about the consequences when refactoring a large codebase. It&#x27;s kind of like reactive global variables. There are legitimate reasons when to use them. But not as a general design principle.<p>That being said: If you&#x27;re dead set on this paradigm you can implement this easily yourself. Create a bootstrapping function that modifies a prototype or class in order to provide functions to register signals and slots and use them wherever you need them.<p>If you use TypeScript you could even use Decorators (e.g. &quot;@Signal&quot; or &quot;@Slot&quot;) which are just higher order functions to have some syntactic sugar like the QT macros.
评论 #43767079 未加载
ksherlock29 days ago
There is a proposal (<a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-signals">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-signals</a>) for standardized signals. Maybe that&#x27;s not what you&#x27;re thinking of. But if it is, there&#x27;s a polyfill and other prior art (eg, preact-signals -- <a href="https:&#x2F;&#x2F;preactjs.com&#x2F;guide&#x2F;v10&#x2F;signals&#x2F;" rel="nofollow">https:&#x2F;&#x2F;preactjs.com&#x2F;guide&#x2F;v10&#x2F;signals&#x2F;</a> -- which are not specific to p&#x2F;react).
seabass-labrax30 days ago
The first thing that comes to mind is that Qt now has a WebAssembly port[1] using Emscripten[2], so depending on your use-case, you could possibly just run Qt on the Web platform and avoid the need for a JavaScript framework entirely.<p>[1]: <a href="https:&#x2F;&#x2F;doc.qt.io&#x2F;qt-5&#x2F;wasm.html" rel="nofollow">https:&#x2F;&#x2F;doc.qt.io&#x2F;qt-5&#x2F;wasm.html</a><p>[2]: <a href="https:&#x2F;&#x2F;emscripten.org" rel="nofollow">https:&#x2F;&#x2F;emscripten.org</a>
solardev29 days ago
Not sure how it works in Qt, but in regular React you&#x27;d just use a shared Context that all the components and their children can access. That way you don&#x27;t have to explicitly pass props and setters and getters back and forth.