Open payne-chris-r opened 7 years ago
new Promise((resolve, reject) => {
- if (false) {
- reject(error);
+ if (error) {
+ reject(false);
}
resolve(true);
});
- });
Oh, I see now. I should have read more carefully. This diff misses your intent.
However it also muddies the common pattern we want them to use when writing their own Promise executors:
new Promise((resolve, reject) => {
if (error) {
reject(error);
}
resolve(true);
});
I like this idea.
Agreed, my intent is simply to show them the guts of a promise. THEN introduce what I've been calling the "catalyst function" that determines whether or not the original promise is resolved or rejected...
I think I do something like this in the delivery. @raq929, will you add our discussion of this issue to delivery notes and then ping @payne-chris-r? Many thanks.
1) Show a promise.
2) Show a promise where the callback makes a decision (and becomes the catalyst for the promise chain):
3) give flip a coin a
setTimeout
<-- so the call takes awhile4) use
fs.writeFile
instead ofsetTimeout
5) Keep going with
.then()