> p1.then(val => doStuff)
>> .catch(err => console.error(err));
>>
>
> Nice: +1
>
On further thought, I'm not so sure. Consider this code, which creates a
directory if it doesn't already exist and then logs "done".
return AFS.stat(path).then(stat => {
if (!stat.isDirectory())
throw new Error("Path is not a directory.");
}, error => {
// Path doesn't exist - create the directory
return AFS.mkdir(path);
}).then(val => console.log("done"));
Breaking the error handler out into its own "fail" method seems to make
this awkward to express because the "fail" callback is assigned to the
"then" transform, instead of the original promise as intended.
I think arrow functions make the two-arg form considerably more
aesthetically pleasing.
- Kevin
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss