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

Commit

Permalink
docs(operators): add documentation for toPromise
Browse files Browse the repository at this point in the history
  • Loading branch information
Wortmann, Jan-Niklas authored and Wortmann, Jan-Niklas committed Jan 4, 2018
1 parent 5059b48 commit 412c024
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions src/operator-docs/utility/toPromise.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
import { OperatorDoc } from '../operator.model';

export const toPromise: OperatorDoc = {
'name': 'toPromise',
'operatorType': 'utility'
export const toPromiseOperator: OperatorDoc = {
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,
it will look for a constructor first in Rx.config.Promise then fall back to the native Promise constructor if available.`
}
],
shortDescription: {
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
.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: ['map', 'subscribe']
};

0 comments on commit 412c024

Please sign in to comment.