Skip to content

Instantly share code, notes, and snippets.

@DiegoVictor
DiegoVictor / events.js
Last active May 15, 2021 23:13
How to use Node.js EventEmmiter
// https://nodejs.org/api/events.html
const EventEmmiter = require("events");
const eventEmmiter = new EventEmmiter();
const cooking = async ({ name }) => ({ name });
const driveTo = async () => true;
const leave = async () => ({ delivered: true });
async function cook({ pizzaOrder, user }) {
console.log(`Cooking a ${pizzaOrder.name}`);