From 362b126325b8f921ca7723cdc2a6ca7936ddda5f Mon Sep 17 00:00:00 2001 From: saiprince2595 Date: Sat, 17 Mar 2018 22:29:15 +0530 Subject: [PATCH 1/3] docs (operators): add documentation for ignoreElements --- src/operator-docs/filtering/ignoreElements.ts | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/filtering/ignoreElements.ts b/src/operator-docs/filtering/ignoreElements.ts index 570b83c7..0d0ef4c8 100644 --- a/src/operator-docs/filtering/ignoreElements.ts +++ b/src/operator-docs/filtering/ignoreElements.ts @@ -1,6 +1,67 @@ import { OperatorDoc } from '../operator.model'; export const ignoreElements: OperatorDoc = { - 'name': 'ignoreElements', - 'operatorType': 'filtering' + name: 'ignoreElements', + operatorType: 'filtering', + signature: 'public ignoreElements(): OperatorFunction', + marbleUrl: 'http://reactivex.io/rxjs/img/ignoreElements.png', + shortDescription: { + description: + 'Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`' + }, + walkthrough: { + description: `

+ ignoreElements + Returns an empty Observable that only calls 'complete' or 'error', based on which one is called by source Observable +

` + }, + examples: [ + { + name: 'Ignores all elements from source', + code: ` + import { interval } from 'rxjs/observable/interval'; + import { take, ignoreElements } from 'rxjs/operators'; + //emit value every 100ms + const source = interval(100); + //ignore everything but complete + const example = source.pipe(take(5), ignoreElements()); + //output: "COMPLETE!" + const subscribe = example.subscribe( + val => console.log('NEXT:',val), + val => console.log('ERROR:',val), + () => console.log('COMPLETE!') + ); + `, + externalLink: { + platform: 'JSBin', + url: 'http://jsbin.com/yiyefelubi/1/edit?js,console' + } + }, + { + name: 'Displaying Error', + code: ` + //emit value every 100ms + const source = Rx.Observable.interval(100); + //ignore everything but error + const error = source + .flatMap(val => { + if(val === 4){ + return Rx.Observable.throw('ERROR AT'val); + } + return Rx.Observable.of(val); + }) + .ignoreElements(); + //output: "ERROR: ERROR AT 4" + const subscribe = error.subscribe( + val => console.log('NEXT:',val), + val => console.log('ERROR:',val), + () => console.log('SECOND COMPLETE!') + ); + `, + externalLink: { + platform: 'JSBin', + url: 'http://jsbin.com/gogonawuze/1/edit?js,console' + } + } + ] }; From 690c8ffc0511ed25dace5cb7dac4d220a33bba94 Mon Sep 17 00:00:00 2001 From: Saiprasad Tirumala Date: Fri, 30 Mar 2018 10:51:19 +0530 Subject: [PATCH 2/3] docs(operators): markdown class added --- src/operator-docs/filtering/ignoreElements.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/filtering/ignoreElements.ts b/src/operator-docs/filtering/ignoreElements.ts index 0d0ef4c8..1e45fed8 100644 --- a/src/operator-docs/filtering/ignoreElements.ts +++ b/src/operator-docs/filtering/ignoreElements.ts @@ -6,8 +6,8 @@ export const ignoreElements: OperatorDoc = { signature: 'public ignoreElements(): OperatorFunction', marbleUrl: 'http://reactivex.io/rxjs/img/ignoreElements.png', shortDescription: { - description: - 'Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`' + description: `Ignores all items emitted by the source Observable and only passes calls of + complete or error` }, walkthrough: { description: `

From 884e75fb9fc1e9fc6d1153bce638eacef3f085e9 Mon Sep 17 00:00:00 2001 From: Saiprasad Tirumala Date: Fri, 30 Mar 2018 10:57:38 +0530 Subject: [PATCH 3/3] docs(operators): flatMap to mergeMap updated --- src/operator-docs/filtering/ignoreElements.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/filtering/ignoreElements.ts b/src/operator-docs/filtering/ignoreElements.ts index 1e45fed8..ba516f53 100644 --- a/src/operator-docs/filtering/ignoreElements.ts +++ b/src/operator-docs/filtering/ignoreElements.ts @@ -44,7 +44,7 @@ export const ignoreElements: OperatorDoc = { const source = Rx.Observable.interval(100); //ignore everything but error const error = source - .flatMap(val => { + .mergeMap(val => { if(val === 4){ return Rx.Observable.throw('ERROR AT'val); } @@ -60,7 +60,7 @@ export const ignoreElements: OperatorDoc = { `, externalLink: { platform: 'JSBin', - url: 'http://jsbin.com/gogonawuze/1/edit?js,console' + url: 'http://jsbin.com/puwenenata/edit?html,js,console' } } ]