On Github hbrysiewicz / sdjs-promises
let lentXavierTent = Promise((resolve, reject) => { // ... resolve(tent) // ... reject(excuse) })here is what that looks like as a promise
lentXavierTent.then((tent) => { // go camping }).catch((excuse) => { // buy a new tent... })and here is how you would then use that promise
let lentXavierTent = Promise((resolve, reject) => { ... }) let lentKatBackpack = Promise((resolve, reject) => { ... }) let lentStuartBag = Promise((resolve, reject) => { ... })here is what those look like as promises
let promises = [lentXavierTent, lentKatBackpack, lentStuartBag] Promise.all(promises).then((campingGear) => { // go camping }).catch((excuse) => { // buy a new tent... })if any of the passed in promises rejects, the all Promise immediately rejects with the value of the promise that rejected
let lentDiannaTent = Promise((resolve, reject) => { ... }) let lentXavierTent = Promise((resolve, reject) => { lentDiannaTent.then(resolve).catch(reject) }) let lentKatBackpack = Promise((resolve, reject) => { ... }) let lentStuartBag = Promise((resolve, reject) => { ... })here is what those look like as promises
let promises = [lentXavierTent, lentKatBackpack, lentStuartBag] Promise.all(promises).then((campingGear) => { // go camping }).catch((excuse) => { // buy a new tent... })if any of the passed in promises rejects, the all Promise immediately rejects with the value of the promise that rejected
Heather Brysiewicz