reactant-share
Version:
A framework for building shared web applications with Reactant
21 lines (18 loc) • 847 B
JavaScript
import { modulesKey } from 'reactant';
import { proxyExecutorKey } from './constants.js';
var applyMethod = function (app, options) {
var module = app.instance[modulesKey][options.module];
if (!module) {
throw new Error("The module '".concat(options.module, "' is not a multiple instances injected module, and it does not exist."));
}
var method = module[options.method];
if (typeof method !== 'function') {
throw new Error("The '".concat(options.method, "' method for module '").concat(options.module, "' does not exist."));
}
// If the method in main thread and use coworker, it should be proxied for execution to a coworker thread.
if (module[proxyExecutorKey]) {
return module[proxyExecutorKey](options);
}
return method.apply(module, options.args);
};
export { applyMethod };