Skip to content

Instantly share code, notes, and snippets.

@Charlyzzz
Created February 25, 2020 04:23
Show Gist options
  • Save Charlyzzz/2b9137285eaec4a5a0e3d91465a0d26d to your computer and use it in GitHub Desktop.
Save Charlyzzz/2b9137285eaec4a5a0e3d91465a0d26d to your computer and use it in GitHub Desktop.
actors.js
const { system, Behaviors } = require('./actors');
const ping = (msg, ctx, sender) => {
ctx.logger.log(msg);
ctx.scheduleOnce(sender, 'ping', 1000);
};
const pong = (msg, ctx, sender) => {
ctx.logger.log(msg);
ctx.scheduleOnce(sender, 'pong', 1000);
};
const main = async () => {
const mySystem = system();
const pingActor = mySystem.spawnActor(ping, 'pinger');
const pongActor = mySystem.spawnActor(pong, 'ponger');
mySystem.tell(pingActor, 'start');
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment