Events
Sending data across flows
In metz, events are transmitted over a Channel
and you use its capabilities through two key functions.
std.createChannelEmitter
This function takes a topic
as a parameter, creates a Channel
for that topic and returns an emitter
which will let you dispatch events.
std.registerChannelListener
This takes two params, a topic
and a listener
. The listener
must return a FlowExecutor
With these params, whenever there’s an event
on the channel for given topic, the listener
is invoked.
For example:
Here’s what it looks like in action:
Play with the code here.
And with that, we have covered all about asynchronous operations that metz has to offer.
Along the way we also learnt everything about designing systems in metz.
But does it look pretty? How does one get those icons? Also, how are we able to show data?
Let’s answer that in the next section!