Skip to content

Commit f727067

Browse files
committed
Commit some missing code
1 parent e53fc92 commit f727067

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

code/babel/babelrc-latest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["latest"],
3+
"plugins": ["transform-runtime"]
4+
}

code/events/async-counter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let counter = 0;
2+
3+
async function listenIncrement() {
4+
await click(incrementEl);
5+
counter += 1;
6+
counterEl.innerHTML = counter;
7+
listenIncrement();
8+
}
9+
10+
listenIncrement();

code/events/callback-counter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let counter = 0;
2+
3+
function updateCounter(n) {
4+
counter += n;
5+
counterEl.innerHTML = counter;
6+
}
7+
8+
incrementEl.addEventListener('click', () => {
9+
updateCounter(1);
10+
});
11+
12+
decrementEl.addEventListener('click', () => {
13+
updateCounter(-1);
14+
});

code/events/observable-counter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const source = Observable.merge(
2+
Observable.fromEvent(incrementBtn, 'click').mapTo(1),
3+
Observable.fromEvent(decrementBtn, 'click').mapTo(-1),
4+
);
5+
6+
source
7+
.scan((acc, curr) => acc + curr, 0)
8+
.subscribe((counter) => {
9+
counterEl.innerHTML = counter;
10+
});

code/installation.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$ npm install --save-dev \
2+
babel-core \
3+
babel-cli \
4+
babel-preset-latest \
5+
babel-plugin-transform-runtime
6+
7+
$ npm install --save babel-runtime

0 commit comments

Comments
 (0)