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

Side by Side Diff: web/inc/luci-operation/operation.ts

Issue 2969643003: [web] Update packages, use TS 2.4 (Closed)
Patch Set: [web] Update packages, use TS 2.4 Created 3 years, 5 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
« no previous file with comments | « web/inc/logdog-stream-view/model.ts ('k') | web/package.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright 2016 The LUCI Authors. All rights reserved. 2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 */ 5 */
6 6
7 namespace luci { 7 namespace luci {
8 8
9 /** 9 /**
10 * An Operation wraps a Promise, adding methods to cancel that Promise. 10 * An Operation wraps a Promise, adding methods to cancel that Promise.
(...skipping 14 matching lines...) Expand all
25 static CANCELLED = new Error('Operation is cancelled'); 25 static CANCELLED = new Error('Operation is cancelled');
26 26
27 private _cancelled = false; 27 private _cancelled = false;
28 private cancelCallbacks = new Array<() => void>(); 28 private cancelCallbacks = new Array<() => void>();
29 29
30 /** 30 /**
31 * Wraps a Promise, returning a Promise whose resolve and reject methods 31 * Wraps a Promise, returning a Promise whose resolve and reject methods
32 * will throw a CANCELLED error if this Operation has been cancelled. 32 * will throw a CANCELLED error if this Operation has been cancelled.
33 */ 33 */
34 async wrap<T>(p: Promise<T>) { 34 async wrap<T>(p: Promise<T>) {
35 return new Promise((resolve, reject) => { 35 return new Promise<T>((resolve, reject) => {
36 p.then( 36 p.then(
37 result => { 37 result => {
38 this.assert(); 38 this.assert();
39 resolve(result); 39 resolve(result);
40 }, 40 },
41 err => { 41 err => {
42 this.assert(); 42 this.assert();
43 reject(err); 43 reject(err);
44 }); 44 });
45 }); 45 });
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 this.cancelCallbacks.splice(index, 1); 101 this.cancelCallbacks.splice(index, 1);
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 /** Perform an asynchronous call. */ 106 /** Perform an asynchronous call. */
107 function asyncCall(fn: () => void) { 107 function asyncCall(fn: () => void) {
108 window.setTimeout(fn, 0); 108 window.setTimeout(fn, 0);
109 } 109 }
110 } 110 }
OLDNEW
« no previous file with comments | « web/inc/logdog-stream-view/model.ts ('k') | web/package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698