https://www.w3schools.com › Js › js_promise.asp
JavaScript Promises - W3SchoolsPromise How To. Here is how to use a Promise: myPromise.then ( function (value) { /* code if successful */ }, function (error) { /* code if some error */ } ); Promise.then () takes two arguments, a callback for success and another for failure. Both are optional, so you can add a callback for success or failure only.
https://developer.mozilla.org › fr › docs › Web › JavaScript › Reference › Global_Objects › Promise
Promise - JavaScript | MDN - MDN Web DocsUn autre exemple simple utilisant Promise et XMLHttpRequest afin de charger une image est disponible sur le dépôt GitHub MDN js-examples. Vous pouvez également voir le résultat. Chaque étape est commentée afin de vous permettre de suivre l'état de la promesse et l'architecture utilisée avec XHR.
https://javascript.info › promise-basics
Promise - The Modern JavaScript TutorialHere’s an example of a promise constructor and a simple executor function with “producing code” that takes time (via setTimeout):
This small example shows the mechanism of a Promise. The testPromise() method is called each time the <button> is clicked. It creates a promise that will be fulfilled, using setTimeout(), to the promise count (number starting from 1) every 1-3 seconds, at random. The Promise() constructor is used to create the promise.
https://developer.mozilla.org › fr › docs › Web › JavaScript › Guide › Using_promises
Utiliser les promesses - JavaScript | MDN - MDN Web DocsPromise.resolve() et Promise.reject() sont des méthodes qui permettent de créer des promesses déjà tenues ou rompues. Promise.all() et Promise.race() sont deux outils de composition qui permettent de mener des opérations asynchrones en parallèle.
https://www.aleksandrhovhannisyan.com › blog › javascript-promise-tricks
JavaScript Promises: Practical Use Cases and ExamplesPromises are a powerful tool for writing asynchronous code in JavaScript. Here are a few interesting use cases.
https://www.toptal.com › javascript › javascript-promises
JavaScript Promises: A Tutorial With Examples - ToptalWe’ll learn the basic vocabulary, and work through a few JavaScript promises examples to introduce the concepts behind them in a practical way. I’ll use one of the more popular implementation libraries, rsvp.js , in the code examples.
https://fr.javascript.info › promise-basics
Promesse (promise) - JavaScriptUne promesse (promise) est un objet spécial en JavaScript qui lie le “producteur de code” et le “consommateur de code” ensemble. En comparant à notre analogie c’est la “liste d’abonnement”.
https://fr.javascript.info › promise-api
Promesse API - JavaScriptJavaScript le langage. Promesses, async/await. 10 avril 2022. Promesse API. Il y a 6 méthodes statiques dans la classe Promise. Nous allons rapidement couvrir leurs usages ici. Promise.all. Disons que nous voulons exécuter de nombreuses promesses en parallèle, et attendre qu’elles soient toutes prêtes.
https://www.javascripttutorial.net › es6 › javascript-promises
JavaScript Promises - JavaScript TutorialA promise is an object that encapsulates the result of an asynchronous operation. A promise starts in the pending state and ends in either a fulfilled state or a rejected state. Use then() method to schedule a callback to be executed when the promise is fulfilled, and catch() method to schedule a callback to be invoked when the promise is rejected.