This repository was archived by the owner on Oct 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathfromPromise.ts
46 lines (44 loc) · 1.5 KB
/
fromPromise.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { OperatorDoc } from '../operator.model';
export const fromPromise: OperatorDoc = {
name: 'fromPromise',
operatorType: 'creation',
signature:
'public static fromPromise(promise: Promise, scheduler: Scheduler): Observable',
parameters: [
{
name: 'promise',
type: 'Promise',
attribute: '',
description: 'The promise to be converted.'
},
{
name: 'scheduler',
type: 'Scheduler',
attribute: 'optional',
description:
'An optional IScheduler to use for scheduling the delivery of the resolved value (or the rejection).'
}
],
shortDescription: {
description: 'Converts a Promise to an Observable.'
},
walkthrough: {
description: `Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an Observable.
If the Promise resolves with a value, the output Observable emits that resolved value as a next,
and then completes. If the Promise is rejected, then the output Observable emits the corresponding Error.`
},
examples: [
{
name: 'Convert the Promise returned by Fetch to an Observable',
code: `
import {fromPromise} from 'rxjs/observable/fromPromise';
const result = fromPromise(fetch('http://github.com/'));
result.subscribe(x => console.log(x), e => console.error(e));`,
externalLink: {
platform: 'JSBin',
url: 'http://jsbin.com/warotosaco/embed?js,console,output'
}
}
],
relatedOperators: ['bindCallback', 'from', 'toPromise']
};