UNPKG

@actorize/core

Version:

Actorize helps building scalable js apps with a messaging system

24 lines 822 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dispatch = void 0; const utils_1 = require("../utils"); async function dispatch(director, recipient, payload, waitTillResponse = false) { const randomActorName = (0, utils_1.randomstring)(); // @ts-expect-error for now its ok const actor = director.registerActor(randomActorName); let returnValue; if (waitTillResponse) { returnValue = new Promise((resolve) => { actor.onMessage((msgs) => { // TODO: just a workaround const msg = msgs[0]; resolve(msg); }); }); } await actor.sendMessage(recipient, payload); return returnValue; } exports.dispatch = dispatch; exports.default = {}; //# sourceMappingURL=dispatch.js.map