Skip to content

Commit

Permalink
Fixed bug in async state handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Jan 14, 2015
1 parent 015adb4 commit 287dcba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
18 changes: 12 additions & 6 deletions lib/AsyncBinaryState.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/AsyncBinaryState.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/AsyncBinaryState.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ module.exports = class AsyncBinaryState

@isOn = isOn

promise = bluebird.resolve handler?()
if handler?
method = bluebird.method handler
else
method = -> bluebird.resolve()

promise.catch => @isOn = not @isOn
method()
.catch (error) =>
@isOn = not isOn

promise
throw error

0 comments on commit 287dcba

Please sign in to comment.