-
Notifications
You must be signed in to change notification settings - Fork 62
docs(operators): add documentation for toPromise #228
base: master
Are you sure you want to change the base?
Changes from 3 commits
412c024
f866871
7098aaa
eda96b6
f83fb3a
fa33d59
c5ae099
c4d20b5
069c14f
e1ad924
ecd3b62
f37338b
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,50 @@ | ||
import { OperatorDoc } from '../operator.model'; | ||
|
||
export const toPromise: OperatorDoc = { | ||
'name': 'toPromise', | ||
'operatorType': 'utility' | ||
name: 'toPromise', | ||
operatorType: 'utility', | ||
signature: 'public toPromise(PromiseCtor: *): Promise<T>', | ||
parameters: [ | ||
{ | ||
name: 'PromiseCtor', | ||
type: '*', | ||
attribute: 'optional', | ||
description: `promise The constructor of the promise. If not provided, | ||
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. Did you mean to have 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. no I think it was a copy paste mistake :) |
||
it will look for a constructor first in Rx.config.Promise then fall back to the native Promise constructor if available.` | ||
} | ||
], | ||
shortDescription: { | ||
description: | ||
'Converts an Observable sequence to a ES2015 compliant promise.' | ||
}, | ||
walkthrough: { | ||
description: `An ES2015 compliant promise which contains the last value from the Observable sequence. | ||
If the Observable sequence is in error, then the Promise will be in the rejected stage. | ||
If the sequence is empty, the Promise will not resolve.`, | ||
extras: [ | ||
{ | ||
type: 'Tip', | ||
text: | ||
'This operator makes reactive programming easy to use for developers who are not used to it.' | ||
} | ||
] | ||
}, | ||
examples: [ | ||
{ | ||
name: 'Just return the emitted value of the observable as a promise', | ||
code: ` | ||
const source = Rx.Observable | ||
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. Can you please change these to use es6 imports |
||
.of(42) | ||
.toPromise(); | ||
|
||
source.then((value) => console.log('Value: %s', value)); | ||
// => Value: 42 | ||
`, | ||
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. How about this example. it is based on https://www.learnrxjs.io/operators/utility/topromise.html
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. for now I would just add a hint. If we use stackblitz one could add a proper example with async await |
||
externalLink: { | ||
platform: 'JSBin', | ||
url: 'http://jsbin.com/fanivejahe/embed?js,console,output' | ||
} | ||
} | ||
], | ||
relatedOperators: ['fromPromise'] | ||
}; |
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.
Let's leave out generics in signature for now.