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

Commit b82118f

Browse files
authored
Merge pull request #208 from JWO719/add-docs-for-last
docs(operators): add documentation for last
2 parents 68910a1 + 8aba465 commit b82118f

File tree

1 file changed

+43
-2
lines changed

1 file changed

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

33
export const last: OperatorDoc = {
4-
'name': 'last',
5-
'operatorType': 'filtering'
4+
name: 'last',
5+
operatorType: 'filtering',
6+
signature: 'public last(predicate: function): Observable',
7+
useInteractiveMarbles: true,
8+
parameters: [
9+
{
10+
name: 'predicate',
11+
type: 'function',
12+
attribute: '',
13+
description: 'The condition any source emitted item has to satisfy.'
14+
}
15+
],
16+
marbleUrl: 'http://reactivex.io/rxjs/img/last.png',
17+
shortDescription: {
18+
description: `Emits only the last value emitted by the source Observable.`
19+
},
20+
walkthrough: {
21+
description: `<p>
22+
<span class="markdown-code">last</span> Returns an Observable that emits only the last item emitted by the source Observable.
23+
</p>
24+
<p>
25+
It optionally takes a predicate function as a parameter,
26+
in which case, rather than emitting the last item from the source Observable,
27+
the resulting Observable will emit the last item from the source Observable that satisfies the predicate.
28+
</p>`
29+
},
30+
examples: [
31+
{
32+
name: 'Get the last number that is divisible by 3',
33+
code: `
34+
const range = Rx.Observable.range(1, 10);
35+
const last = range.last(x => x % 3 === 0);
36+
last.subscribe(x => console.log(x));
37+
// Logs below values
38+
// 9
39+
`,
40+
externalLink: {
41+
platform: 'JSBin',
42+
url: 'http://jsbin.com/reqacoselu/embed?html,js,console'
43+
}
44+
}
45+
],
46+
relatedOperators: ['takeLast', 'first']
647
};

0 commit comments

Comments
 (0)