Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit 5342b0d

Browse files
Wortmann, Jan-NiklasWortmann, Jan-Niklas
Wortmann, Jan-Niklas
authored and
Wortmann, Jan-Niklas
committed
docs(operators):
add documentation for toPromise #133
1 parent 5059b48 commit 5342b0d

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed
+43-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
11
import { OperatorDoc } from '../operator.model';
22

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']
646
};

0 commit comments

Comments
 (0)