Last active
March 1, 2019 08:22
-
-
Save keyvan-m-sadeghi/f62dc2e1ec2b367f97d03519c2b7bec3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Nancy { | |
constructor(executor) { | |
... | |
const laterCalls = []; | |
const callLater = getMember => callback => new Nancy(resolve => laterCalls.push(() => resolve(getMember()(callback)))); | |
const members = { | |
... | |
[states.pending]: { | |
... | |
then: callLater(() => this.then), | |
catch: callLater(() => this.catch) | |
} | |
}; | |
... | |
const apply = (value, state) => { | |
if (this.state === states.pending) { | |
... | |
for (const laterCall of laterCalls) { | |
laterCall(); | |
} | |
} | |
}; | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment