【发布时间】:2020-09-19 08:39:03
【问题描述】:
我正在使用以下软件包进行演示应用
https://www.npmjs.com/package/@opuscapita/fsm-workflow-core
无论文档中写的是什么,我都会遵循所有步骤。但是出现错误 machineDefinition 未定义
这是我的代码 https://codesandbox.io/s/inspiring-banzai-xumr2?file=/src/index.js
var http = require("http");
let { MachineDefinition, Machine } = require("@opuscapita/fsm-workflow-core");
var machineDefinition = new MachineDefinition({
schema: {
initialState: "start",
finalStates: ["finish"],
transitions: [{ from: "start", event: "run", to: "finish" }]
}
});
const object = { status: "none" };
const machine = new Machine(machineDefinition);
machine
.start({ object })
.then(({ object }) => {
console.log(machine.currentState({ object }));
// start
return machine.sendEvent({ object, event: "start" });
})
.then(({ object }) => {
console.log(machine.currentState({ object }));
// finish
});
//create a server object:
http
.createServer(function(req, res) {
res.write("Hello World!"); //write a response to the client
res.end(); //end the response
})
.listen(8080); //the server object listens on port 8080
你能告诉我我哪里做错了吗?
这个包还有一点是Apache-2.0 license。我可以在我的实际项目中使用这个包吗?
【问题讨论】:
标签: javascript node.js node-modules fsm