From 60a1d964ae54f5e6b23c950cc914d967ddf5f9cc Mon Sep 17 00:00:00 2001 From: Hardik Pithva Date: Sat, 26 May 2018 15:20:29 +0530 Subject: [PATCH 1/2] fix: remove submodule --- rxjs-docs | 1 - 1 file changed, 1 deletion(-) delete mode 160000 rxjs-docs diff --git a/rxjs-docs b/rxjs-docs deleted file mode 160000 index 5059b48c..00000000 --- a/rxjs-docs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5059b48c083853b48eeabdc2272c56edf4e2443b From 82be7afde73d2b267f17966fcd568abc2956b366 Mon Sep 17 00:00:00 2001 From: Hardik Pithva Date: Sat, 26 May 2018 15:36:02 +0530 Subject: [PATCH 2/2] docs(operators): add documentation for defaultIfEmpty --- .../conditional/defaultIfEmpty.ts | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/conditional/defaultIfEmpty.ts b/src/operator-docs/conditional/defaultIfEmpty.ts index 591449f1..da41724c 100644 --- a/src/operator-docs/conditional/defaultIfEmpty.ts +++ b/src/operator-docs/conditional/defaultIfEmpty.ts @@ -1,6 +1,67 @@ import { OperatorDoc } from '../operator.model'; export const defaultIfEmpty: OperatorDoc = { - 'name': 'defaultIfEmpty', - 'operatorType': 'conditional' + name: 'defaultIfEmpty', + operatorType: 'conditional', + signature: 'public defaultIfEmpty(defaultValue: any): Observable', + marbleUrl: 'http://reactivex.io/rxjs/img/defaultIfEmpty.png', + parameters: [ + { + name: 'defaultValue', + type: 'any', + attribute: 'optional default: null', + description: 'The default value used if the source Observable is empty.' + } + ], + shortDescription: { + description: `Emits a given value if the source Observable completes without emitting any + next value, otherwise mirrors the source Observable. + `, + extras: [ + { + type: 'Tip', + text: ` + If the source Observable turns out to be empty, then this operator will emit a default value. + ` + } + ] + }, + walkthrough: { + description: ` +

+ defaultIfEmpty emits the values emitted by the source + Observable or a specified default value if the source Observable is empty (completes + without having emitted any next value). +

+ ` + }, + examples: [ + { + name: `If no clicks happen in 3 seconds, then emit 'no clicks'`, + code: ` + import { fromEvent } from 'rxjs/observable/fromEvent'; + import { interval } from 'rxjs/observable/interval'; + import { defaultIfEmpty, takeUntil } from 'rxjs/operators'; + + const clicks = fromEvent(document, 'click'); + const result = clicks.pipe( + takeUntil(interval(3000)), + defaultIfEmpty('no clicks') + ); + + result.subscribe(x => console.log(x)); + + /* + Example console output + no clicks + */ + `, + externalLink: { + platform: 'JSBin', + url: 'http://jsbin.com/verovam/embed?js,console,output' + } + } + ], + relatedOperators: ['empty', 'last'], + additionalResources: [] };