Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.
Merged
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
38 changes: 36 additions & 2 deletions src/operator-docs/filtering/single.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
import { OperatorDoc } from '../operator.model';

export const single: OperatorDoc = {
'name': 'single',
'operatorType': 'filtering'
name: 'single',
operatorType: 'filtering',
signature: 'public single(predicate: Function): Observable<T>',
parameters: [
{
name: 'predicate',
type: 'Function',
attribute: '',
description:
'A predicate function to evaluate items emitted by the source Observable.'
}
],
marbleUrl: 'http://reactivex.io/rxjs/img/single.png',
shortDescription: {
description: `Returns an Observable that emits the single item emitted by the source Observable
that matches a specified predicate, if that Observable emits one such item.
If the source Observable emits more than one such item or no such items, notify of an IllegalArgumentException
or NoSuchElementException respectively.`
},
examples: [
{
name: 'Emit first number passing predicate',
code: `
//emit (1,2,3,4,5)
const source = Rx.Observable.from([1, 2, 3, 4, 5]);
//emit one item that matches predicate
const example = source.single(val => val === 4);
//output: 4
const subscribe = example.subscribe(val => console.log(val));
`,
externalLink: {
platform: 'JSBin',
url: 'http://jsbin.com/solecibuza/embed?js,console'
}
}
]
};