This repository has been 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
docs(operators): add documentation for toPromise #228
Open
niklas-wortmann
wants to merge
12
commits into
ReactiveX:master
Choose a base branch
from
niklas-wortmann:add-docs-for-toPromise
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
412c024
docs(operators): add documentation for toPromise
f866871
docs(operators): fix documentation due to copy paste errors
7098aaa
docs(operators): add short description
eda96b6
docs(operators): fix typo in toPromise doc
f83fb3a
Merge branch 'master' into add-docs-for-toPromise
niklas-wortmann fa33d59
docs(documentation): add es 6 import to toPromise documentation
c5ae099
Merge branch 'master' of github.com:ReactiveX/rxjs-docs into add-docs…
c4d20b5
Merge branch 'master' into add-docs-for-toPromise
niklas-wortmann 069c14f
Merge branch 'add-docs-for-toPromise' of github.com:JWO719/rxjs-docs …
e1ad924
docs(operators): add tip for async await
ecd3b62
Merge branch 'master' into add-docs-for-toPromise
niklas-wortmann f37338b
Merge branch 'master' into add-docs-for-toPromise
ashwin-sureshkumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,55 @@ | ||
import { OperatorDoc } from '../operator.model'; | ||
|
||
export const toPromise: OperatorDoc = { | ||
'name': 'toPromise', | ||
'operatorType': 'utility' | ||
name: 'toPromise', | ||
operatorType: 'utility', | ||
signature: 'public toPromise(PromiseCtor: *): Promise', | ||
parameters: [ | ||
{ | ||
name: 'PromiseCtor', | ||
type: '*', | ||
attribute: 'optional', | ||
description: `The constructor of the promise. If not provided, | ||
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.' | ||
}, | ||
{ | ||
type: 'Tip', | ||
text: 'After calling toPromise you can make use of async/await!' | ||
} | ||
] | ||
}, | ||
examples: [ | ||
{ | ||
name: 'Just return the emitted value of the observable as a promise', | ||
code: ` | ||
import {of} from 'rxjs/observable/of'; | ||
|
||
const source = of(42) | ||
.toPromise(); | ||
|
||
source.then((value) => console.log('Value: %s', value)); | ||
// => Value: 42 | ||
`, | ||
externalLink: { | ||
platform: 'JSBin', | ||
url: 'http://jsbin.com/fanivejahe/embed?js,console,output' | ||
} | ||
} | ||
], | ||
relatedOperators: ['fromPromise'] | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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