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

docs(operators): add fromPromise documentation #229

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions src/operator-docs/creation/fromPromise.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
import { OperatorDoc } from '../operator.model';

export const fromPromise: OperatorDoc = {
'name': 'fromPromise',
'operatorType': 'creation'
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']
};