From 918090db3ca7e05f579c97bc517f8b9ed18601b5 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Tue, 22 Mar 2016 10:46:40 +0100 Subject: [PATCH 1/2] Fix the collaboration.js example The getParticipantByName method is async. --- examples/processes/collaboration.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/processes/collaboration.js b/examples/processes/collaboration.js index bf0633f..cdcab34 100644 --- a/examples/processes/collaboration.js +++ b/examples/processes/collaboration.js @@ -2,10 +2,10 @@ exports.Task_2 = function( data , done ){ // after arriving ot "Task 2" we start process 1 - var partnerProcess = this.getParticipantByName("My First Process"); - partnerProcess.triggerEvent("Start Event 1"); - done(data); - done(); + this.getParticipantByName("My First Process", function(err, partnerProcess) { + partnerProcess.triggerEvent("Start Event 1"); + done(data); + }); }; From d29e547ee8aa3475143dd4c54e89baf79eb40780 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Tue, 22 Mar 2016 10:54:34 +0100 Subject: [PATCH 2/2] Fix README accordingly to the previous commit --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e5ceda2..a19da27 100644 --- a/README.md +++ b/README.md @@ -235,12 +235,13 @@ These processes must be created together: The collaboration of the processes is then implemented in the handlers. For example, it is possible to get a partner process by name and then send an event to this process. This is frequently done to start the partner process: - exports.Task_2 = function(data, done) { - // after arriving ot "Task 2" we start process 1 - var partnerProcess = this.getParticipantByName("My First Process"); - partnerProcess.triggerEvent("Start Event 1"); - done(data); - }; + exports.Task_2 = function(data, done) { + // after arriving ot "Task 2" we start process 1 + this.getParticipantByName("My First Process", function(err, partnerProcess) { + partnerProcess.triggerEvent("Start Event 1"); + done(data); + }); + }; However, another option is to get all outgoing message flows and send a message along these flows. In the current example we have exactly one flow, so sending the message is done by: