appium/appium — pull request #3886 by sebv (2014-10-23 19:55:51+00:00)
Title: Fixed release bug when released element is not valid, promise poc

Note: This contains new code pattern proposal for this project, this is aimed at extensive discussion.

Following discussion on slack this week I felt people would benefits from a 'promise in action' example. At the same time when fixing this bug I had to introduce extra level of callbacks in an already complicated code, so I felt compelled to use promises. I've refrained from using complicated promise patterns so should be easy to follow.

Since the discussion is probably gonna go this way, if we decide to move to generator later, it is a good intermediary step, all you have to do is make replace the fcall/then by yield call, and catch by regular try/catch.

If we choose not to use promise, I'll convert it to Async.js so no worry.

This also contains:
- Bugfix for https://github.com/appium/appium/issues/3855. Now when we default an element in release, we also compute the current element position. In the case the release fails with status 7, we strip the el argument from the release gesture and try again.

pinging @jlipps, @0x1mason , @Jonahss , @imurchie , @bootstraponline feel free to invite more.