Skip to content

Commit

Permalink
Added an async faq addressing issue gruntjs#121
Browse files Browse the repository at this point in the history
  • Loading branch information
Damon Oehlman committed Apr 13, 2012
1 parent 24d627e commit 398c1a7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/faq.md
Expand Up @@ -26,3 +26,17 @@ Note that the `phantomjs` executable needs to be in the system `PATH` for grunt
* [How to set the path and environment variables in Windows](http://www.computerhope.com/issues/ch000549.htm)
* [Where does $PATH get set in OS X 10.6 Snow Leopard?](http://superuser.com/questions/69130/where-does-path-get-set-in-os-x-10-6-snow-leopard)
* [How do I change the PATH variable in Linux](https://www.google.com/search?q=How+do+I+change+the+PATH+variable+in+Linux)

## Why doesn't my asynchronous task work?! <a name="why-doesnt-my-async-task-work" href="#why-doesnt-my-async-task-work"" title="Link to this section">⚑</a>

Chances are it's because you have forgotten to use the tell the current task that you are using [async](https://github.com/cowboy/grunt/blob/master/docs/api_task.md#this-async-grunt-task-current-async) behaviour.

For simplicity of use and a clean, readable code Grunt uses a synchronous coding style. If you are creating a task that does integrate with an asynchronous module or you prefer to write in an asynchronous style be sure to call `this.async()` within the task body and grunt will provide you with a callback function to use, e.g.:

```js
grunt.registerTask('asyncme', 'Your task description goes here.', function() {
var callback = this.async();

doSomethingAsync(callback);
});
```

0 comments on commit 398c1a7

Please sign in to comment.