Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {zeroPage, zeroFS} from "../zero";
import limit from "limit-concurrency-decorator";
class HotReload {
constructor() {
zeroPage.on("setSiteInfo", this.onSetSiteInfo.bind(this));
this.hotreloads = [];
this.dbschema = null;
}
@limit(1)
async getDbschema() {
if(this.dbschema) {
return this.dbschema;
}
this.dbschema = JSON.parse(await zeroFS.readFile("dbschema.json"));
return this.dbschema;
}
register(tableName, f) {
if(!this.hotreloads[tableName]) {
this.hotreloads[tableName] = [];
}
this.hotreloads[tableName].push(f);
}