Comment

Comment by mg

When I need to signal something across my application, I use events:

    window.dispatchEvent(new Event('counterChange'));
And every part of the application that wants to react to it can subscribe via

    window.addEventListener('counterChange', () => {
        ... do something ...
    });
Anything wrong with that?
parent mg 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton