react-native-executorch
Version:
An easy way to run AI models in react native with ExecuTorch
22 lines (21 loc) • 761 B
JavaScript
;
import { ResourceFetcher } from '../utils/ResourceFetcher';
import { getError } from '../Error';
export class BaseModule {
static onDownloadProgressCallback = () => {};
static async load(...sources) {
try {
const paths = await ResourceFetcher.fetchMultipleResources(this.onDownloadProgressCallback, ...sources);
await this.nativeModule.loadModule(...paths);
} catch (error) {
throw new Error(getError(error));
}
}
static async forward(..._args) {
throw new Error('forward method is not implemented in the BaseModule class. Please implement it in the derived class.');
}
static onDownloadProgress(callback) {
this.onDownloadProgressCallback = callback;
}
}
//# sourceMappingURL=BaseModule.js.map