Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

docs (operators): add documentation for ignoreElements #301

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions src/operator-docs/filtering/ignoreElements.ts
Original file line number Diff line number Diff line change
@@ -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<any, never>',
marbleUrl: 'http://reactivex.io/rxjs/img/ignoreElements.png',
shortDescription: {
description: `Ignores all items emitted by the source Observable and only passes calls of
<span class="markdown-code">complete</span> or <span class="markdown-code">error</span>`
},
walkthrough: {
description: `<p>
<span class="markdown-code">ignoreElements</span>
Returns an empty Observable that only calls 'complete' or 'error', based on which one is called by source Observable
</p>`
},
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to update this to pipeable operators and remove global? Thanks!

const source = Rx.Observable.interval(100);
//ignore everything but error
const error = source
.mergeMap(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/puwenenata/edit?html,js,console'
}
}
]
};