add states in index.js

This commit is contained in:
lucaspalomodevelop 2022-10-31 12:58:45 +01:00
parent 71e3e44e3d
commit 9f131a1702

View File

@ -7,20 +7,27 @@ var app = {};
app.render = engine.render;
app.CONST = engine.CONST;
app.renderFile = (filePath) => {
this.setState({ status: 0, statusMSG: "read file" });
let file = fs.readFileSync(filePath, "utf8");
this.setState({ status: 0, statusMSG: "parse file" });
file = JSON.parse(file);
this.setState({ status: 0, statusMSG: "set Selfpath" });
file["_SELFPATH_"] = path.dirname(filePath);
return engine.render(file);
};
app.setStateFunction = function (callback) {
app.stateCallback = callback;
};
app.setState = ({ status, statusMSG }) => {
if (app.stateCallback != undefined) {
app.stateCallback({ status, statusMSG });
}
};
app.setStateFunction = function (callback) {
app.stateCallback = callback;
this.setState({ status: 0, statusMSG: "set Statefunction" });
this.setState({ status: 0, statusMSG: "JSSTE is ready" });
};
// app.log = function({status, statusMSG}){
// };