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

Commit ff1eda8

Browse files
committed
refactor(operators): Add comment for expected output
Added the expected console output for the jsbin and inline examples. Also modified package.json to include the angular-cli changes only on one PR
1 parent e32b89a commit ff1eda8

File tree

2 files changed

+72
-19
lines changed

2 files changed

+72
-19
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.5",
51+
"@angular/cli": "1.6.0",
5252
"@angular/compiler-cli": "5.1.1",
5353
"@angular/language-service": "5.1.1",
5454
"@angular/service-worker": "5.1.1",

src/operator-docs/transformation/bufferToggle.ts

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,94 @@ export const bufferToggle: OperatorDoc = {
4646
import { fromEvent } from 'rxjs/observable/fromEvent';
4747
import { interval } from 'rxjs/observable/interval';
4848
import { empty } from 'rxjs/observable/empty';
49-
import { map, bufferToggle } from 'rxjs/operators';
49+
import { bufferToggle } from 'rxjs/operators';
5050
51-
const clicks$ = fromEvent(document, 'click');
52-
const openings$ = interval(1000);
53-
const buffered$ = clicks$.pipe(
54-
map(e => {return {X: e.clientX, Y: e.clientY};}),
55-
bufferToggle(openings$, i => i % 2 ? interval(500) : empty())
51+
const clicks = fromEvent(document, 'click', e => ({x: e.clientX, y: e.clientY}));
52+
const openings = interval(1000);
53+
const buffered = clicks.pipe(
54+
bufferToggle(openings, i => i % 2 ? interval(500) : empty())
5655
);
57-
buffered$.subscribe(x => console.log(x));
56+
/*
57+
Expected console output:
58+
59+
[]
60+
61+
[[object Object] {
62+
x: 156,
63+
y: 165
64+
}, [object Object] {
65+
x: 156,
66+
y: 165
67+
}, [object Object] {
68+
x: 156,
69+
y: 165
70+
}]
71+
72+
[]
73+
74+
[]
75+
*/
76+
buffered.subscribe(x => console.log(x));
5877
`,
5978
externalLink: {
6079
platform: 'JSBin',
61-
url: 'http://jsbin.com/nuriyod/1/embed?js,console,output'
80+
url: 'http://jsbin.com/nuriyod/3/embed?js,console,output'
6281
}
6382
},
6483
{
6584
name:
6685
'Start buffering all the click events when you press the "S" key and close the buffer when you press the "E" key',
6786
code: `
6887
import { fromEvent } from 'rxjs/observable/fromEvent';
69-
import { filter, map, bufferToggle } from 'rxjs/operators';
88+
import { filter, bufferToggle } from 'rxjs/operators';
7089
71-
const clicks$ = fromEvent(document, 'click');
72-
const keyUp$ = fromEvent(document,'keyup');
73-
const openings$ = keyUp$.pipe(filter(e => e.key === 's'));
74-
const closing$ = keyUp$.pipe(filter(e => e.key === 'e'));
75-
const buffered$ = clicks$.pipe(
76-
map(e => {return {X: e.clientX, Y: e.clientY};}),
77-
bufferToggle(openings$, _ => closing$)
90+
const clicks = fromEvent(document, 'click', e => ({x: e.clientX, y: e.clientY}));
91+
const keyUp = fromEvent(document,'keyup');
92+
const openings = keyUp.pipe(filter(e => e.key === 's'));
93+
const closing = keyUp.pipe(filter(e => e.key === 'e'));
94+
const buffered = clicks.pipe(
95+
bufferToggle(openings, _ => closing)
7896
);
79-
buffered$.subscribe(x => console.log(x));
97+
/*
98+
Expected console output:
99+
100+
[[object Object] {
101+
x: 147,
102+
y: 135
103+
}, [object Object] {
104+
x: 147,
105+
y: 135
106+
}, [object Object] {
107+
x: 144,
108+
y: 135
109+
}, [object Object] {
110+
x: 144,
111+
y: 135
112+
}, [object Object] {
113+
x: 144,
114+
y: 135
115+
}]
116+
117+
[[object Object] {
118+
x: 144,
119+
y: 135
120+
}, [object Object] {
121+
x: 144,
122+
y: 135
123+
}]
124+
125+
[[object Object] {
126+
x: 143,
127+
y: 136
128+
}]
129+
130+
*/
131+
132+
buffered.subscribe(x => console.log(x));
80133
`,
81134
externalLink: {
82135
platform: 'JSBin',
83-
url: 'http://jsbin.com/vurobel/8/embed?js,console,output'
136+
url: 'http://jsbin.com/vurobel/11/embed?js,console,output'
84137
}
85138
}
86139
],

0 commit comments

Comments
 (0)