Open nicolasembleton opened 10 years ago
It's not dummy at all.
Process Engine
describes the workflow using tasks and flows.
The built-in task types:
start
: mark the start of process, must be the first taskend
: mark the end of process.service
: automatic task type that execute any code in itdecision
: Certain things can only be done under certain circumstances. The decision task is used to mark the fork and join of execution pathhuman
: manual task type, they are assigned by engine, e.g. place it in the task list, the engine expect confirmation to continue the executionThe flow is something to connect the tasks and can take a condition function if the from
task is decision task.
human task service is used to manipulate the task list.
Therefore, for question 1, you can manipulate external data in service
task, basically you provide a function that take a process variables and complete function. You can do whatever things in your function, once it's done, call complete
to let engine continue execution.
'Auto UW': {type: 'service', action: function (variables, complete) {
variables.autoUnderwritingResult = variables.age < 60;
console.log('Auto underwriting service task result:', variables.autoUnderwritingResult);
complete();
}}
for question 2, you need to use 'human' task type to model the task that needs to be completed by a user. And once it's done, you can call humanTaskService.complete
to let the engine continue execution. For this one, you can see test/Insurance.spec.js
for complete code.
Please let me know if you have any other questions.
Thanks. I think I got it now.
Is it possible to execute code from the action: fn() handler for a human task?
Because process instance is a event emitter, you can attach listener on it to listen after
event.
processInstance.on('before', function (task) {
// write your code here
console.log(task);
});
Gotcha. Pretty nice. Didn't think about that... I think it would just need 1 real-world example with access to outside data, persistence and a couple things like that to make it really practical and helpful to get started.
But thanks. Got it to work nicely.
Yes, agree.My daily work is enterprise Java stuff. This project is my side project that inspired by some Java process engine I used but rather lightweight. Glad to see you like it.
I think it would be very beneficial to have a clearer flow sample. There are many examples of how individually things work, but I find that the following things are unclear to me, even though I've looked at the sources, examples and tests:
Sorry for the dummy questions, but even after a couple hours of trial & error, it's still not very clear to me the way it should work. But I really love the way it's built and the features so I try to have it working.