Tags "promise" Result

how to use es6-promises with typescript?

I read this SO question but having trouble getting promises to work with typescript. Hopefully we can make a clear guide. This is for a server/node project. I'm actually using latest iojs, but targeting ES5 as output. $ tsd query es6-promise --action install --save $ npm install --save es6-promise // typescript code: /// <reference path="../

it1352 0 2020-10-30

Create empty promise in angular?

I would to to something like this: var promise = IAmAEmptyPromise; if(condition){ promise = ApiService.getRealPromise(); } promise.then(function(){ //do something }); So I want to declare a promise, which can be resolved using then. However this promise may be overwritten by another promise, which returns content. Later I want to resol

it1352 1 2019-05-08

Angular 2 can't find Promise,Map,Set and Iterator

After installing angular 2, My typescript compiler keep getting some errors about not finding Promise,Map,Set and Iterator. Until now I ignored them but now I need Promise so my code will work. import {Component} from 'angular2/core'; @Component({ selector: 'greeting-cmp', template: `<div>{{ asyncGreeting | async}}</div>` }) ex

it1352 1 2019-05-08

How is a promise/defer library implemented?

How is a promise/defer library like q implemented? I was trying to read the source code but found it pretty hard to understand, so I thought it'd be great if someone could explain to me, from a high level, what are the techniques used to implement promises in single-thread JS environments like Node and browsers. Solution I find it harder to expla

it1352 1 2019-05-22

Difference between resolve and return in promise JS

var p1 = new Promise (function (res, rej){ res(42); }).then((result) => {return result;}); **If I have ** return result, is this promise resolved or not? What does a "resolved promise" mean? Solution Java Script is a single threaded language. This simplifies most tasks; but, it means asynchronous tasks must be handled in a callback func

it1352 4 2019-05-22

Understanding the Promises/A specification

The Promises/A specification is one of the smallest specifications. Hence, implementing it is the best way to understand it. The following answer by Forbes Lindesay walks us through the process of implementing the Promises/A specification, Basic Javascript promise implementation attempt. However, when I tested it the results were not satisfactory

it1352 1 2019-06-25

How JavaScript promises work behind the scenes

I'm so much confused about what happens behind the scenes when promise is produced and consume. Please clarify my points and sorry for my weak English. blank object is created with new keyword Promise constructor is called and new keyword set the this of Promise constructor points to the blank object this = blankobject. Promise constructor receiv

it1352 0 2020-10-30

Cancel a delayed Bluebird promise

How to reject a delayed Promise: const removeDelay = Promise.delay(5000).then(() => { removeSomething(); }); //Undo event - if it is invoked before 5000 ms, then undo deleting removeDelay.reject(); // reject is not a method Solution Bluebird v3 We no longer need to declare a Promise as 'cancellable' (documentation): no setup code re

it1352 0 2020-09-21

Swift PromiseKit: Equivalent to when() which executes sequentially?

I'm using PromiseKit with Swift, which has been very handy so far. One of the functions they provide is when(), which allows you to have an array of any number of promises and execute something only once ALL of them have completed. However, the promises in the array are executed in parallel. I have not found any function that allows me to execute

it1352 6 2020-07-04