What is the specific term for the callback that you pass to the javascript Promise constructor?

StackOverflow https://stackoverflow.com/questions/21563140

Вопрос

The ES6 Promise takes a callback as argument:

var promise = new Promise(function(resolve, reject) {
  // do a thing, possibly async, then…

  if (/* everything turned out fine */) {
    resolve("Stuff worked!");
  }
  else {
    reject(Error("It broke"));
  }
});

Is there a term for these callback-you-pass-to-create-a-promise's?

Это было полезно?

Решение

The ECMAScript 6 Language Specification calls it an executor. See section 24.4.3.1.

Другие советы

They are usually referred to as "targets".

I would just call them "callbacks"

But if you want to be specific then success and error callbacks.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top