News for hackers. Stuff that matters.
Re:A proposal to add signals to JavaScript by everybackdoor on Sunday March 31, 2024 @06:08PM (#39888512)
You can also fire events on pretty much any object, essentially creating a channel where the message bus queue is the vm event queue.
Re:A proposal to add signals to JavaScript by lelanthran on Monday April 01, 2024 @12:53AM (#39891032)
> You can also fire events on pretty much any object,

Only if you have a reference to the object.

The reason I made up my own message queue pub/sub is because events required a lot of complexity in acquiring the correct reference to the correct object or subtree in the DOM.

With pub/sub type message queue, any element can emit a message with subject "POST /getnetpage" and the function listening for (subscribed) POST messages emits a RESPONSE message when the response comes back. This lets a third element listen (subscribe) for a "RESPONSE FROM /getnextpage" subject message, and handle it.

None of the 3 parties in the above need to have a reference to each other, nor do they even have to know about each other, and I can inject some nice observability tools because I can just add a subscriber for specific message types, which makes debugging a breeze.