OLD | NEW |
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(); |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 /** @private {!Promise<T>} */ | 30 /** @private {!Promise<T>} */ |
31 this.promise_ = new Promise(function(resolve, reject) { | 31 this.promise_ = new Promise(function(resolve, reject) { |
32 this.resolve_ = resolve; | 32 this.resolve_ = resolve; |
33 this.reject_ = reject; | 33 this.reject_ = reject; |
34 }.bind(this)); | 34 }.bind(this)); |
35 } | 35 } |
36 | 36 |
37 PromiseResolver.prototype = { | 37 PromiseResolver.prototype = { |
38 /** @return {!Promise<T>} */ | 38 /** @return {!Promise<T>} */ |
39 get promise() { return this.promise_; }, | 39 get promise() { |
40 set promise(p) { assertNotReached(); }, | 40 return this.promise_; |
| 41 }, |
| 42 set promise(p) { |
| 43 assertNotReached(); |
| 44 }, |
41 | 45 |
42 /** @return {function(T=): void} */ | 46 /** @return {function(T=): void} */ |
43 get resolve() { return this.resolve_; }, | 47 get resolve() { |
44 set resolve(r) { assertNotReached(); }, | 48 return this.resolve_; |
| 49 }, |
| 50 set resolve(r) { |
| 51 assertNotReached(); |
| 52 }, |
45 | 53 |
46 /** @return {function(*=): void} */ | 54 /** @return {function(*=): void} */ |
47 get reject() { return this.reject_; }, | 55 get reject() { |
48 set reject(s) { assertNotReached(); }, | 56 return this.reject_; |
| 57 }, |
| 58 set reject(s) { |
| 59 assertNotReached(); |
| 60 }, |
49 }; | 61 }; |
OLD | NEW |