One event, independent widgets
Place an order: the response informs ORDER/PLACED, and the badge and the log update on their own. Add a widget after some orders: it subscribes, and gets the last order at once.
In a module: returns a subscription with remove().
Calls every subscriber of the event with the data.
Like inform, and a later subscriber is called with the last data right away.
Forgets the last data of the event.
// PHP: one call informs every module that listens
return (new AsyncResponse())
->call('bigpipe-util/dist/core/Arbiter', 'informState', [
'ORDER/PLACED',
['id' => 1004, 'product' => 'Mouse', 'count' => 4],
])
->send();
// JavaScript: in any module
new Arbiter().subscribe('ORDER/PLACED', order => {
badge.textContent = order.count;
});
Place an order: the response informs ORDER/PLACED, and the badge and the log update on their own. Add a widget after some orders: it subscribes, and gets the last order at once.