Note that there are some explanatory texts on larger screens.

plurals
  1. POJake task firing complete before completion of async task
    text
    copied!<p>I am testing Jake out as a possible replacement for Rake on a primarily javascript project. Now one thing that I am finding as odd is that the completion event is being triggered BEFORE the event has completed.</p> <p>Here is an example:</p> <pre><code>task('some_task_1', {async: true}, function () { console.log("|- Doing something"); var execCallback = function() { console.log(" |- Done something"); complete(); }; setTimeout(execCallback, 2000); }); task('some_task_2', {async: true}, function () { console.log("|- Doing something else"); var execCallback = function() { console.log(" |- Done something else"); complete(); }; setTimeout(execCallback, 2000); }); task('task_runner', {async: true}, function () { var firstTask = jake.Task['some_task_1']; var secondTask = jake.Task['some_task_2']; firstTask.addListener("complete", function() { secondTask.invoke(); }); secondTask.addListener("complete", function() { complete(); }); firstTask.invoke(); }); task('default', function () { jake.Task['task_runner'].invoke(); }); </code></pre> <p>I would have expected that the output would be:</p> <pre><code>|- Doing something |- Done something |- Doing something else |- Done something else </code></pre> <p>However what I actually get is:</p> <pre><code>|- Doing something |- Doing something else |- Done something |- Done something else </code></pre> <p>So is there some magic around how the async should be working in Jake? as it seems to be somehow firing a complete event before its actually finished the exec.</p> <p>== EDIT ==</p> <p>Just so there is no confusion I am using version 0.5.16 of Jake <a href="https://github.com/mde/jake" rel="nofollow">https://github.com/mde/jake</a></p> <p>== EDIT 2 ==</p> <p>Have posted another example which now should show the exact issue in a clearer way as it seems to be related to tasks within tasks which are async.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload