hybridgroup/cylon — pull request #247 by lorenwest (2014-12-26 06:39:02+00:00)
Title: Support asynchronous robot commands

This pull request adds support for robot commands that aren't able to produce results synchronously.

If a command cannot produce immediate results, it returns a [promise](https://www.google.com/search?q=javascript+promises) instead of the results.

Clients of the command can use the promise directly if it knows the command is asynchronous - usually from the documentation. If the client doesn't know if a command is asynchronous, it can inspect the result to see if it's `then`able. This was the change made to the API in this pull request.

This resolved an issue in my device where the results couldn't be returned immediately upon command invocation. The alternatives were awkward - either require the client to wait a bit and call a different command for the results, or wait on a custom event designated for the results of the command. Neither option was appropriate because the results may have come from a different caller.