Created first action and basic timer reducer
Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
parent
e004529eb8
commit
e096653b2e
9
lib/actions/timer_actions.dart
Normal file
9
lib/actions/timer_actions.dart
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import 'package:time_progress_calculator/models/timer.dart';
|
||||||
|
|
||||||
|
abstract class Action {}
|
||||||
|
|
||||||
|
class UpdateTimerAction extends Action {
|
||||||
|
final Timer updatedTimer;
|
||||||
|
|
||||||
|
UpdateTimerAction(this.updatedTimer);
|
||||||
|
}
|
7
lib/reducers/app_state_reducer.dart
Normal file
7
lib/reducers/app_state_reducer.dart
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import 'package:time_progress_calculator/actions/timer_actions.dart';
|
||||||
|
import 'package:time_progress_calculator/models/app_state.dart';
|
||||||
|
import 'package:time_progress_calculator/reducers/timer_reducer.dart';
|
||||||
|
|
||||||
|
AppState appReducer(AppState state, Action action) {
|
||||||
|
return AppState(timer: timersReducer(state.timer, action));
|
||||||
|
}
|
10
lib/reducers/timer_reducer.dart
Normal file
10
lib/reducers/timer_reducer.dart
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import 'package:time_progress_calculator/actions/timer_actions.dart';
|
||||||
|
import 'package:time_progress_calculator/models/timer.dart';
|
||||||
|
import 'package:redux/redux.dart';
|
||||||
|
|
||||||
|
final timersReducer = combineReducers<Timer>(
|
||||||
|
[TypedReducer<Timer, UpdateTimerAction>(_updateTimer)]);
|
||||||
|
|
||||||
|
Timer _updateTimer(Timer timer, UpdateTimerAction action) {
|
||||||
|
return action.updatedTimer;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user