Created
February 25, 2020 04:23
-
-
Save Charlyzzz/2b9137285eaec4a5a0e3d91465a0d26d to your computer and use it in GitHub Desktop.
actors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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