From e3b24a8d8c813904a6d0114fc06734e8392a88f4 Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Thu, 4 Jan 2018 22:31:29 +0100 Subject: [PATCH 1/4] docs(operators): add fromPromise documentation --- src/operator-docs/creation/fromPromise.ts | 42 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/creation/fromPromise.ts b/src/operator-docs/creation/fromPromise.ts index a287456d..8be260ee 100644 --- a/src/operator-docs/creation/fromPromise.ts +++ b/src/operator-docs/creation/fromPromise.ts @@ -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, scheduler: Scheduler): Observable', + parameters: [ + { + name: 'promise', + type: 'Promise', + 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));`, + externalLink: { + platform: 'JSBin', + url: 'http://jsbin.com/warotosaco/embed?js,console,output' + } + } + ], + relatedOperators: ['bindCallback', 'from', 'toPromise'] }; From cda197a6d621c9558ecb16ddcb7cf0755b23843e Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Tue, 16 Jan 2018 21:07:07 +0100 Subject: [PATCH 2/4] docs(operators): fix typo fix typo in the description of fromPromise operator --- src/operator-docs/creation/fromPromise.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operator-docs/creation/fromPromise.ts b/src/operator-docs/creation/fromPromise.ts index 8be260ee..abebfe17 100644 --- a/src/operator-docs/creation/fromPromise.ts +++ b/src/operator-docs/creation/fromPromise.ts @@ -17,7 +17,7 @@ export const fromPromise: OperatorDoc = { type: 'Scheduler', attribute: 'optional', description: - 'An optional IScheduler to use for scheduling the delivery of the resolved value (or the rejection).s' + 'An optional IScheduler to use for scheduling the delivery of the resolved value (or the rejection).' } ], shortDescription: { From 89e9c8934d7914b423a72eb97243f9c76b464d85 Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Thu, 1 Feb 2018 21:00:30 +0100 Subject: [PATCH 3/4] docs(operators): add es6 import --- src/operator-docs/creation/fromPromise.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/operator-docs/creation/fromPromise.ts b/src/operator-docs/creation/fromPromise.ts index abebfe17..ac7ff76d 100644 --- a/src/operator-docs/creation/fromPromise.ts +++ b/src/operator-docs/creation/fromPromise.ts @@ -32,7 +32,9 @@ export const fromPromise: OperatorDoc = { { name: 'Convert the Promise returned by Fetch to an Observable', code: ` - const result = Rx.Observable.fromPromise(fetch('http://myserver.com/')); + import {fromPromise} from 'rxjs/observable/fromPromise'; + + const result = fromPromise(fetch('http://myserver.com/')); result.subscribe(x => console.log(x), e => console.error(e));`, externalLink: { platform: 'JSBin', From 34d3e819b4bb896b42f2190ec654cac3bb3b2db5 Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Mon, 5 Feb 2018 20:31:02 +0100 Subject: [PATCH 4/4] docs(operators): change server in example --- src/operator-docs/creation/fromPromise.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/operator-docs/creation/fromPromise.ts b/src/operator-docs/creation/fromPromise.ts index ac7ff76d..02df6a71 100644 --- a/src/operator-docs/creation/fromPromise.ts +++ b/src/operator-docs/creation/fromPromise.ts @@ -4,11 +4,11 @@ export const fromPromise: OperatorDoc = { name: 'fromPromise', operatorType: 'creation', signature: - 'public static fromPromise(promise: Promise, scheduler: Scheduler): Observable', + 'public static fromPromise(promise: Promise, scheduler: Scheduler): Observable', parameters: [ { name: 'promise', - type: 'Promise', + type: 'Promise', attribute: '', description: 'The promise to be converted.' }, @@ -34,7 +34,7 @@ export const fromPromise: OperatorDoc = { code: ` import {fromPromise} from 'rxjs/observable/fromPromise'; - const result = fromPromise(fetch('http://myserver.com/')); + const result = fromPromise(fetch('http://github.com/')); result.subscribe(x => console.log(x), e => console.error(e));`, externalLink: { platform: 'JSBin',