Skip to content

Instantly share code, notes, and snippets.

@renatoapcosta
Created February 28, 2022 17:32
Show Gist options
  • Save renatoapcosta/cfa7617dc07d7c4aba9f186de6753497 to your computer and use it in GitHub Desktop.
Save renatoapcosta/cfa7617dc07d7c4aba9f186de6753497 to your computer and use it in GitHub Desktop.
Javacript Async

Javacript Async

Callback

O termo retorno de chamada é apenas um termo sofisticado para uma função.

Chamamos a função de função de retorno de chamada onde volta em um momento posterior.

Aqui está a função de retorno simples:

function cb(data) {
  // algo com data
}

someAsyncMethod(cb);

Promessas

const egg = chicken.makeChick(); //devolve uma promessa

egg
  .then(chick => raiseChick())   // success
  .catch(badEgg => throw badEgg) // fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment