1 |
- {"version":3,"file":"defaultIfEmpty.js","sourceRoot":"","sources":["../../src/operator/defaultIfEmpty.ts"],"names":[],"mappings":";AAEA,+BAA8C,6BAA6B,CAAC,CAAA;AAK5E,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAA0D,YAAsB;IAAtB,4BAAsB,GAAtB,mBAAsB;IAC9E,MAAM,CAAC,+BAAW,CAAO,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAFe,sBAAc,iBAE7B,CAAA","sourcesContent":["\nimport { Observable } from '../Observable';\nimport { defaultIfEmpty as higherOrder } from '../operators/defaultIfEmpty';\n\n/* tslint:disable:max-line-length */\nexport function defaultIfEmpty<T>(this: Observable<T>, defaultValue?: T): Observable<T>;\nexport function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue?: R): Observable<T | R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Emits a given value if the source Observable completes without emitting any\n * `next` value, otherwise mirrors the source Observable.\n *\n * <span class=\"informal\">If the source Observable turns out to be empty, then\n * this operator will emit a default value.</span>\n *\n * <img src=\"./img/defaultIfEmpty.png\" width=\"100%\">\n *\n * `defaultIfEmpty` emits the values emitted by the source Observable or a\n * specified default value if the source Observable is empty (completes without\n * having emitted any `next` value).\n *\n * @example <caption>If no clicks happen in 5 seconds, then emit \"no clicks\"</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));\n * var result = clicksBeforeFive.defaultIfEmpty('no clicks');\n * result.subscribe(x => console.log(x));\n *\n * @see {@link empty}\n * @see {@link last}\n *\n * @param {any} [defaultValue=null] The default value used if the source\n * Observable is empty.\n * @return {Observable} An Observable that emits either the specified\n * `defaultValue` if the source Observable emits no items, or the values emitted\n * by the source Observable.\n * @method defaultIfEmpty\n * @owner Observable\n */\nexport function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue: R = null): Observable<T | R> {\n return higherOrder<T, R>(defaultValue)(this);\n}\n"]}
|