Use on
function when you want to listen from client only.
This declares an event which gets triggered with emit from the client.
function on(eventName: string, fn: Function) => void
// No arg
on("foo:imReady", () => {
console.log("I'm ready to go!");
});
// With arg
on("foo:printMyDelivery", (delivery: string) => {
console.log(`delivery received: ${delivery}`);
});
// Direct function call
on("foo:spawnMyCar", spawnCar);