react-async-states-utils
Version:
utilities for react-async-states package
30 lines (27 loc) • 996 B
JavaScript
import { isSource, requestContext } from 'async-states';
function run(keyOrSource, ...args) {
return runImpl(keyOrSource, null, undefined, ...args);
}
function runLane(keyOrSource, lane, ...args) {
return runImpl(keyOrSource, null, lane, ...args);
}
function runInContext(keyOrSource, context, ...args) {
return runImpl(keyOrSource, context, undefined, ...args);
}
function runLaneInContext(keyOrSource, context, lane, ...args) {
return runImpl(keyOrSource, context, lane, ...args);
}
function runImpl(keyOrSource, context, lane, ...args) {
if (isSource(keyOrSource)) {
return keyOrSource.getLane(lane).run(...args);
}
if (typeof keyOrSource === "string") {
let instance = requestContext(context).get(keyOrSource);
if (instance) {
return instance.actions.run.apply(null, args);
}
}
return undefined;
}
export { run, runInContext, runLane, runLaneInContext };
//# sourceMappingURL=run.js.map