This repository was archived by the owner on Oct 1, 2018. It is now read-only.
File tree 1 file changed +43
-3
lines changed
src/operator-docs/utility
1 file changed +43
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { OperatorDoc } from '../operator.model' ;
2
2
3
- export const toPromise : OperatorDoc = {
4
- 'name' : 'toPromise' ,
5
- 'operatorType' : 'utility'
3
+ export const toPromiseOperator : OperatorDoc = {
4
+ name : 'toPromise' ,
5
+ operatorType : 'utility' ,
6
+ signature : 'public toPromise(PromiseCtor: *): Promise<T>' ,
7
+ parameters : [
8
+ {
9
+ name : 'PromiseCtor' ,
10
+ type : '*' ,
11
+ attribute : 'optional' ,
12
+ description : `promise The constructor of the promise. If not provided,
13
+ it will look for a constructor first in Rx.config.Promise then fall back to the native Promise constructor if available.`
14
+ }
15
+ ] ,
16
+ shortDescription : {
17
+ description : `An ES2015 compliant promise which contains the last value from the Observable sequence.
18
+ If the Observable sequence is in error, then the Promise will be in the rejected stage.
19
+ If the sequence is empty, the Promise will not resolve.` ,
20
+ extras : [
21
+ {
22
+ type : 'Tip' ,
23
+ text :
24
+ 'This operator makes reactive programming easy to use for developers who are not used to it.'
25
+ }
26
+ ]
27
+ } ,
28
+ examples : [
29
+ {
30
+ name : 'Just return the emitted value of the observable as a promise' ,
31
+ code : `
32
+ const source = Rx.Observable
33
+ .of(42)
34
+ .toPromise();
35
+
36
+ source.then((value) => console.log('Value: %s', value));
37
+ // => Value: 42
38
+ ` ,
39
+ externalLink : {
40
+ platform : 'JSBin' ,
41
+ url : 'http://jsbin.com/fanivejahe/embed?js,console,output'
42
+ }
43
+ }
44
+ ] ,
45
+ relatedOperators : [ 'map' , 'subscribe' ]
6
46
} ;
You can’t perform that action at this time.
0 commit comments