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

Commit 78bb829

Browse files
author
Diedrik De Mits
committed
docs(operators): Add documentation for bufferCount
Add documentation for bufferCount to close #110
1 parent 3535dce commit 78bb829

File tree

2 files changed

+84
-3
lines changed

2 files changed

+84
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"zone.js": "0.8.14"
4949
},
5050
"devDependencies": {
51-
"@angular/cli": "1.6.0",
51+
"@angular/cli": "1.6.5",
5252
"@angular/compiler-cli": "5.1.1",
5353
"@angular/language-service": "5.1.1",
5454
"@angular/service-worker": "5.1.1",
Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,87 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const bufferCount: OperatorDoc = {
4-
'name': 'bufferCount',
5-
'operatorType': 'transformation'
4+
name: 'bufferCount',
5+
operatorType: 'transformation',
6+
signature: ` bufferCount(bufferSize: number, startBufferEvery: number): Observable<T[]>`,
7+
parameters: [
8+
{
9+
name: 'bufferSize',
10+
type: 'number',
11+
attribute: '',
12+
description: `The maximum size of the buffer emitted.`
13+
},
14+
{
15+
name: 'startBufferEvery',
16+
type: 'number',
17+
attribute: 'optional',
18+
description: `Interval at which to start a new buffer. For example if startBufferEvery is 2,
19+
then a new buffer will be started on every other value from the source.
20+
A new buffer is started at the beginning of the source by default.`
21+
}
22+
],
23+
marbleUrl: 'http://reactivex.io/rxjs/img/bufferCount.png',
24+
shortDescription: {
25+
description: `
26+
Buffers the source Observable values until the size hits the maximum <span class="markdown-code">bufferSize</span> given.
27+
<span class="informal">
28+
Collects values from the past as an array,
29+
and emits that array only when its size reaches <span class="markdown-code">bufferSize</span>.
30+
</span>`
31+
},
32+
walkthrough: {
33+
description: `
34+
Buffers a number of values from the source Observable
35+
by <span class="markdown-code">bufferSize</span> then emits the buffer and clears it,
36+
and starts a new buffer each <span class="markdown-code">startBufferEvery</span> values.
37+
If <span class="markdown-code">startBufferEvery</span> is not provided or is null,
38+
then new buffers are started immediately at the start of the source and when each buffer closes and is emitted.
39+
`
40+
},
41+
examples: [
42+
{
43+
name: 'Every two clicks, emit those two click events as an array',
44+
code: `
45+
import { fromEvent } from 'rxjs/observable/fromEvent';
46+
import { map, bufferCount } from 'rxjs/operators';
47+
48+
const clicks$ = fromEvent(document, 'click');
49+
const buffered$ = clicks$.pipe(
50+
map(e => {return {X: e.clientX, Y: e.clientY};}),
51+
bufferCount(2)
52+
);
53+
buffered$.subscribe(x => console.log(x));
54+
`,
55+
externalLink: {
56+
platform: 'JSBin',
57+
url: 'http://jsbin.com/ceripaf/1/embed?js,console,output'
58+
}
59+
},
60+
{
61+
name: 'On every click, emit the last two click events as an array',
62+
code: `
63+
import { fromEvent } from 'rxjs/observable/fromEvent';
64+
import { map, bufferCount } from 'rxjs/operators';
65+
66+
const clicks$ = fromEvent(document, 'click');
67+
const buffered$ = clicks$.pipe(
68+
map(e => {return {X: e.clientX, Y: e.clientY};}),
69+
bufferCount(2, 1)
70+
);
71+
buffered$.subscribe(x => console.log(x));
72+
`,
73+
externalLink: {
74+
platform: 'JSBin',
75+
url: 'http://jsbin.com/cenuwip/1/embed?js,console,output'
76+
}
77+
}
78+
],
79+
relatedOperators: [
80+
'buffer',
81+
'bufferTime',
82+
'bufferToggle',
83+
'bufferWhen',
84+
'pairwise',
85+
'windowCount'
86+
]
687
};

0 commit comments

Comments
 (0)