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 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: [] };