Skip to content

Instantly share code, notes, and snippets.

@keyvan-m-sadeghi
Last active March 1, 2019 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keyvan-m-sadeghi/f62dc2e1ec2b367f97d03519c2b7bec3 to your computer and use it in GitHub Desktop.
Save keyvan-m-sadeghi/f62dc2e1ec2b367f97d03519c2b7bec3 to your computer and use it in GitHub Desktop.
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