Javascript Promises in 10 Minutes

Опубликовано: 12 Февраль 2019
на канале: DevSage
5,311
158

What's a Promise?
A Promise is an object that acts as a placeholder for some value or operation that is soon to complete or return. Promises are similar to callbacks in that they are both used to control the execution order of a program. If you have 2 asynchronous (not occuring in any particular order) events A and B, and you need to ENSURE that Event B begins ONLY AFTER Event A completes, you can wrap Event A with a Promise object. This promise executes Event A and then gives you the option to either 'resolve' or 'reject' the Promise.

The Promise should be resolved if Event A was executed successfully with no errors. When a Promise is resolved, a special success callback function is triggered. This callback can execute Event B. A Promise should be rejected if Event A failed to complete successfully or produced an error. When a Promise is rejected, a special failure callback is triggered that can be used to carry out error handling tasks.


🌎 Find Me Here:

Twitter:   / realdevsage  
Ebooks: https://payhip.com/devsage
Discord:   / discord  
Merch: https://cottonbureau.com/people/devsage


Смотрите видео Javascript Promises in 10 Minutes онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал DevSage 12 Февраль 2019. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 5,311 раз и оно понравилось 158 посетителям.