Yahoo Search Búsqueda en la Web

Resultado de búsqueda

  1. Promise Syntax. let myPromise = new Promise (function(myResolve, myReject) { // "Producing Code" (May take some time) myResolve (); // when successful. myReject (); // when error. }); // "Consuming Code" (Must wait for a fulfilled Promise) myPromise.then( function(value) { /* code if successful */ }, function(error) { /* code if some error */ } );

  2. 29 de nov. de 2023 · 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.

  3. 14 de ago. de 2022 · let promise = new Promise((resolve, reject) => { setTimeout(() => reject(new Error("Whoops!")), 1000); }); // .catch(f) is the same as promise.then(null, f) promise.catch(alert); // shows "Error: Whoops!" after 1 second. The call .catch(f) is a complete analog of .then(null, f), it’s just a shorthand.

  4. 12 de sept. de 2020 · Examples of Converting Callbacks to Promises. Dynamically Loading Scripts in a Specific Order. Reading Data from a Store (Chrome Extension API) 3. Sleeping in JavaScript. JavaScript Promises in Review. Attributions. 1. Mocking API Calls for UI Development.

  5. Este pequeño ejemplo muestra el mecanismo de un Promise. El método testPromise() se llama cada vez que se hace clic en <button>. Crea una promesa que se cumplirá, usando setTimeout(), para el conteo de promesas (número a partir de 1) cada 1-3 segundos, al azar. El constructor Promise() se usa para crear la promesa.

  6. 21 de mar. de 2024 · A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already-created promises, this guide will explain consumption of returned promises before explaining how to create them.

  7. Ember.js is a great example of such a framework. There are several libraries that implement the Promises/A+ specification. We’ll learn the basic vocabulary, and work through a few JavaScript promises examples to introduce the concepts behind them in a practical way.