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

Commit ad6b74c

Browse files
Merge pull request #193 from ashwin-sureshkumar/issue-96
docs(operators): add documentation for single
2 parents 3777cb9 + eb04d6f commit ad6b74c

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed
Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const single: OperatorDoc = {
4-
'name': 'single',
5-
'operatorType': 'filtering'
4+
name: 'single',
5+
operatorType: 'filtering',
6+
signature: 'public single(predicate: Function): Observable<T>',
7+
parameters: [
8+
{
9+
name: 'predicate',
10+
type: 'Function',
11+
attribute: '',
12+
description:
13+
'A predicate function to evaluate items emitted by the source Observable.'
14+
}
15+
],
16+
marbleUrl: 'http://reactivex.io/rxjs/img/single.png',
17+
shortDescription: {
18+
description: `Returns an Observable that emits the single item emitted by the source Observable
19+
that matches a specified predicate, if that Observable emits one such item.
20+
If the source Observable emits more than one such item or no such items, notify of an IllegalArgumentException
21+
or NoSuchElementException respectively.`
22+
},
23+
examples: [
24+
{
25+
name: 'Emit first number passing predicate',
26+
code: `
27+
//emit (1,2,3,4,5)
28+
const source = Rx.Observable.from([1, 2, 3, 4, 5]);
29+
//emit one item that matches predicate
30+
const example = source.single(val => val === 4);
31+
//output: 4
32+
const subscribe = example.subscribe(val => console.log(val));
33+
`,
34+
externalLink: {
35+
platform: 'JSBin',
36+
url: 'http://jsbin.com/solecibuza/embed?js,console'
37+
}
38+
}
39+
]
640
};

0 commit comments

Comments
 (0)