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

Commit 4150bd8

Browse files
Merge pull request #226 from hardikpthv/iss-124
docs(operators): add documentation for window
2 parents 5cce3ae + 7c21b07 commit 4150bd8

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

rxjs-docs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 5059b48c083853b48eeabdc2272c56edf4e2443b
Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,68 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const windowOperator: OperatorDoc = {
4-
'name': 'window',
5-
'operatorType': 'transformation'
4+
name: 'window',
5+
operatorType: 'transformation',
6+
signature:
7+
'public window(windowBoundaries: Observable<any>): Observable<Observable<T>>',
8+
parameters: [
9+
{
10+
name: 'windowBoundaries',
11+
type: 'Observable<any>',
12+
attribute: '',
13+
description:
14+
'An Observable that completes the previous window and starts a new window.'
15+
}
16+
],
17+
marbleUrl: 'http://reactivex.io/rxjs/img/window.png',
18+
shortDescription: {
19+
description: `
20+
Branch out the source Observable values as a nested Observable
21+
whenever <span class="markdown-code">windowBoundaries</span> emits.
22+
`,
23+
extras: [
24+
{
25+
type: 'Tip',
26+
text: `
27+
It's like <a href="#/operators/buffer" class="markdown-code">buffer</a>,
28+
but emits a nested Observable instead of an array.
29+
`
30+
}
31+
]
32+
},
33+
walkthrough: {
34+
description: `
35+
<p>
36+
Returns an Observable that emits windows of items it collects
37+
from the source Observable. The output Observable emits connected,
38+
non-overlapping windows. It emits the current window and opens a new
39+
one whenever the Observable <span class="markdown-code">windowBoundaries</span>
40+
emits an item. Because each window is an Observable, the output is a higher-order Observable.
41+
</p>
42+
`
43+
},
44+
examples: [
45+
{
46+
name: 'In every window of 1 second each, emit at most 2 click events',
47+
code: `
48+
const clicks = Rx.Observable.fromEvent(document, 'click');
49+
const interval = Rx.Observable.interval(1000);
50+
const result = clicks.window(interval)
51+
.map(win => win.take(2)) // each window has at most 2 emissions
52+
.mergeAll(); // flatten the Observable-of-Observables
53+
result.subscribe(x => console.log(x));
54+
`,
55+
externalLink: {
56+
platform: 'JSBin',
57+
url: 'http://jsbin.com/racefub/embed?js,console,output'
58+
}
59+
}
60+
],
61+
relatedOperators: [
62+
'windowCount',
63+
'windowTime',
64+
'windowToggle',
65+
'windowWhen',
66+
'buffer'
67+
]
668
};

0 commit comments

Comments
 (0)