-
Notifications
You must be signed in to change notification settings - Fork 62
docs(operators): add fromPromise documentation #229
base: master
Are you sure you want to change the base?
Changes from 1 commit
e3b24a8
cda197a
89e9c89
34d3e81
a31728d
3d8adac
3266e74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' | ||
} | ||
], | ||
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));`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add expected output also. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'] | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.