Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Created June 7, 2018 14:39
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 cromwellryan/eec26e35b9fe5ecb4db99b61914dd645 to your computer and use it in GitHub Desktop.
Save cromwellryan/eec26e35b9fe5ecb4db99b61914dd645 to your computer and use it in GitHub Desktop.
Notes from the Wes Bos workshop at https://seesparkbox.com using https://github.com/wesbos/Web-App-Workshop
/* Wes' original example is great, but we've found the following
* example of https://github.com/wesbos/Web-App-Workshop/blob/master/notes/02%20-%20Promises.md
* to read really well and keep us from putting too much in our `then` functions.
*/
const logError = (err) => console.log('Something Happened!', err);
getTheWeatherFor('Dayton')
.then(getPicturesOfWeather)
.then(resizePicturesOfWeather)
.then(uploadNewPictures)
.then(console.log)
.catch(logError);
/* Reason:
* We can do this, because `(data) => func(data)` is creating an anonymous
* function with the same signature (shape) as `func(data)`. You don't need
* to wrap the `func(data)` call in an anonymous function.
@davekiss
Copy link

davekiss commented Jun 7, 2018

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment