Improve `Barrier`
Closed this issue · 3 comments
Resolver and rejecter should return the barrier itself, to allow chaining.
Lines 1 to 2 in 02057e5
Also, perhaps check if the barrier has been resolved already with given result, and make it noop, or fail if it has been resolved or rejected with a different result.
The first take on it caused a critical bug in host code (see #10). The change has been reverted for now, but upon a post-mortem investigation, although I am not able to reproduce the problem in Jest tests in the repo, it looks like the problem can be avoided by ensuring that versions of resolveRef
and rejectRef
passed into executor
here:
Line 37 in ffd9f37
Although, pay attention that here:
Lines 69 to 70 in ffd9f37
resolved
and reject
should be wrapped, I guess, to return instance of res
rather than this
.
Also, perhaps, revisit the typing, rely on the standard Promise
types?
Seems to work fine now.