How to use es6-promise.Promise:
173 174 175 176 177 178 179 180 181 182
return this.sendRequestAndRouteResponse(request .get(url), callback); }; GraphRequest.prototype.routeResponseToPromise = function (requestBuilder) { var _this = this; return new es6_promise_1.Promise(function (resolve, reject) { _this.routeResponseToCallback(requestBuilder, function (err, body) { if (err != null) { reject(err); }
26
34
5
See more examples
How to use es6-promise.resolve:
83 84 85 86 87 88 89 90 91 92
// Dispatch to callbacks and resolve/reject promises. this._callbacks.forEach(function(callback, i) { // Callback can return an obj, to resolve, or a promise, to chain. // See waitFor() for why this might be useful. Promise.resolve(callback(payload)).then(function() { resolves[i](payload); }, function() { rejects[i](new Error('Dispatcher callback unsuccessful')); });
How to use es6-promise.all:
130 131 132 133 134 135 136 137 138 139 140
*/ waitFor: function(/*array*/ promiseIndexes, /*function*/ callback) { var selectedPromises = promiseIndexes.map(function(index) { return this._promises[index]; }, this); return Promise.all(selectedPromises).then(callback); } };