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

Commit e3b24a8

Browse files
Wortmann, Jan-NiklasWortmann, Jan-Niklas
Wortmann, Jan-Niklas
authored and
Wortmann, Jan-Niklas
committed
docs(operators): add fromPromise documentation
1 parent 5059b48 commit e3b24a8

File tree

1 file changed

+40
-2
lines changed

1 file changed

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

33
export const fromPromise: OperatorDoc = {
4-
'name': 'fromPromise',
5-
'operatorType': 'creation'
4+
name: 'fromPromise',
5+
operatorType: 'creation',
6+
signature:
7+
'public static fromPromise(promise: Promise<T>, scheduler: Scheduler): Observable<T>',
8+
parameters: [
9+
{
10+
name: 'promise',
11+
type: 'Promise<T>',
12+
attribute: '',
13+
description: 'The promise to be converted.'
14+
},
15+
{
16+
name: 'scheduler',
17+
type: 'Scheduler',
18+
attribute: 'optional',
19+
description:
20+
'An optional IScheduler to use for scheduling the delivery of the resolved value (or the rejection).s'
21+
}
22+
],
23+
shortDescription: {
24+
description: 'Converts a Promise to an Observable.'
25+
},
26+
walkthrough: {
27+
description: `Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an Observable.
28+
If the Promise resolves with a value, the output Observable emits that resolved value as a next,
29+
and then completes. If the Promise is rejected, then the output Observable emits the corresponding Error.`
30+
},
31+
examples: [
32+
{
33+
name: 'Convert the Promise returned by Fetch to an Observable',
34+
code: `
35+
const result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
36+
result.subscribe(x => console.log(x), e => console.error(e));`,
37+
externalLink: {
38+
platform: 'JSBin',
39+
url: 'http://jsbin.com/warotosaco/embed?js,console,output'
40+
}
41+
}
42+
],
43+
relatedOperators: ['bindCallback', 'from', 'toPromise']
644
};

0 commit comments

Comments
 (0)