#Looking for an explanation of Promises

2 messages · Page 1 of 1 (latest)

balmy cave
#

I'm seeing that apparently promises only take 1 parameter, but when I look at it, I feel like I see 2. Would someone mind trying to explain why it's 1? Here's an example a teacher gave.

function executor(resolve, reject) {
  let connection = ndb.connect(ip);
  if (connection.ok) {
    resolve(connection.socket);
  } else {
    reject(connection.error);
  }
}

new Promise(executor);
lyric plank
#

new Promise takes 1 function that receives 2 parameters