Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: ui/webui/resources/js/cr/promise_resolver.js

Issue 1758013002: WebUI: Allow rejecting a promise that is returned from cr.sendWithPromise(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« ui/webui/resources/js/cr.js ('K') | « ui/webui/resources/js/cr.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview PromiseResolver is a helper class that allows creating a 6 * @fileoverview PromiseResolver is a helper class that allows creating a
7 * Promise that will be fulfilled (resolved or rejected) some time later. 7 * Promise that will be fulfilled (resolved or rejected) some time later.
8 * 8 *
9 * Example: 9 * Example:
10 * var resolver = new PromiseResolver(); 10 * var resolver = new PromiseResolver();
11 * resolver.promise.then(function(result) { 11 * resolver.promise.then(function(result) {
12 * console.log('resolved with', result); 12 * console.log('resolved with', result);
13 * }); 13 * });
14 * ... 14 * ...
15 * ... 15 * ...
16 * resolver.resolve({hello: 'world'}); 16 * resolver.resolve({hello: 'world'});
17 */ 17 */
18 18
19 /** 19 cr.define('cr', function() {
Dan Beam 2016/03/02 19:17:40 why does this need to be namespaced to cr.*?
dpapad 2016/03/02 20:02:09 Moved one level up.
20 * @constructor 20 console.log('promise_resolver.js running');
21 */ 21 /** @constructor */
22 function PromiseResolver() { 22 function PromiseResolver() {
23 /** @type {!Function} */ 23 /** @type {!Function} */
24 this.resolve; 24 this.resolve;
25 25
26 /** @type {!Function} */ 26 /** @type {!Function} */
27 this.reject; 27 this.reject;
28 28
29 /** @type {!Promise} */ 29 /** @type {!Promise} */
30 this.promise = new Promise(function(resolve, reject) { 30 this.promise = new Promise(function(resolve, reject) {
31 this.resolve = resolve; 31 this.resolve = resolve;
32 this.reject = reject; 32 this.reject = reject;
33 }.bind(this)); 33 }.bind(this));
34 } 34 }
35
36 return {
37 PromiseResolver: PromiseResolver
38 };
39 });
OLDNEW
« ui/webui/resources/js/cr.js ('K') | « ui/webui/resources/js/cr.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698