Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
jason chan
31,009 PointsDoes anyone know how promises work?
Does anyone know how promises work?
1 Answer
Cindy Lea
Courses Plus Student 6,497 PointsHere is an excerpt from that explains promises better from html5rocks.com (http://www.html5rocks.com/en/tutorials/es6/promises/) :
At their most basic, promises are a bit like event listeners except:
A promise can only succeed or fail once. It cannot succeed or fail twice, neither can it switch from success to failure or vice versa If a promise has succeeded or failed and you later add a success/failure callback, the correct callback will be called, even though the event took place earlier This is extremely useful for async success/failure, because you're less interested in the exact time something became available, and more interested in reacting to the outcome.
...........
A promise can be:
fulfilled The action relating to the promise succeeded rejected The action relating to the promise failed pending Hasn't fulfilled or rejected yet settled Has fulfilled or rejected.