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 1 commit
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
42 changes: 40 additions & 2 deletions src/operator-docs/creation/fromPromise.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
import { OperatorDoc } from '../operator.model';

export const fromPromise: OperatorDoc = {
'name': 'fromPromise',
'operatorType': 'creation'
name: 'fromPromise',
operatorType: 'creation',
signature:
'public static fromPromise(promise: Promise<T>, scheduler: Scheduler): Observable<T>',
parameters: [
{
name: 'promise',
type: 'Promise<T>',
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).s'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think there's a small typo at end of sentence (or the rejection).s

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, you're right. Thanks for the hint. Will fix it this afternoon.

}
],
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: `
const result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
result.subscribe(x => console.log(x), e => console.error(e));`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change these to es6 imports, there is an incoming PR from @btroncone converting the existing examples.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add expected output also.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be rather confusing in this case. Because the operator is more or less like a cast and doesn't manipulate the output. What do you think? Of course I can add an output, but I think it won't add much value in this case.

externalLink: {
platform: 'JSBin',
url: 'http://jsbin.com/warotosaco/embed?js,console,output'
}
}
],
relatedOperators: ['bindCallback', 'from', 'toPromise']
};