Promises Warm Up

One of the most frustrating things about browser automation is that, while the human brain can handle things like wait a few minutes for the page to load and don't click until a button is on the page, a computer isn’t always so bright.

For that reason, you need to have a strong handle on handling async interactions before you dig into browser automation. Before the WebScraping Workshop, take some time to refresh your memory on how Promises work!

Practice: Promise It Won’t Hurt Workshop

Download the Promise It Won’t Hurt Workshop package from Node School.

  npm install -g promise-it-wont-hurt

You can run the commandline tool in your terminal by running:

  promise-it-wont-hurt

Learn more, if you’re curious, in the README.

You should aim to complete, at minimum, the Warm Up & Fulfill a Promise & Reject a Promise

Reading

Feel free to get started on the exercises immediately, or, if you prefer to warm up by reading first - we recommend the following resources.

Resources

Note: If you get stuck in the workshop, the solutions are all included in the repo if you dig far enough.

Note: If NodeSchool doesn’t work on your machine, of you don’t like the commandline tool - check out this other promises workshop

Note: If you already feel solid on using promises - work on Learn Generators instead

Wrap Up

Review the following questions and come up with some theories

  1. What are the states of a promise?
  2. What is the difference between a callback, a promise or a generator?
  3. Why do we have Promises when we already have Callbacks?
  4. Is it critical that we write Promises all the time?
  5. Is jQuery using promises?

Check out one take on the answers here: Promises Q&A Answers

Lesson Search Results

Showing top 10 results