-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-2.ts
30 lines (23 loc) · 845 Bytes
/
app-2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Action } from "./ngrx-falso/ngrx";
import { incrementadorAction, decrementadorAction, multiplicarAction, dividirAction, resetearAction } from "./contador/contador.actions"
function reducer(state = 10, action: Action) {
switch (action.type) {
case 'INCREMENTAR':
return state += 1;
case 'DECREMENTAR':
return state -= 1;
case 'MULTIPLICAR':
return state * action.payload;
case 'DIVIDIR':
return state / action.payload;
case 'RESETEAR':
return state = 0;
default:
return state;
}
}
console.log(reducer(10, incrementadorAction));
console.log(reducer(10, decrementadorAction));
console.log(reducer(10, multiplicarAction));
console.log(reducer(10, dividirAction));
console.log(reducer(10, resetearAction));