Skip to content

Commit abdc96a

Browse files
committed
refactor: initial state
1 parent 241f3b7 commit abdc96a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Future main() async {
1111

1212
final store = await configureStore<AppState>((builder) {
1313
builder.withReducer(reducer);
14-
builder.withPreloadedState(AppState(status: {}, todos: List.unmodifiable([])));
14+
builder.withPreloadedState(AppState.initialState());
1515

1616
if (Config.reduxDevtoolsEnabled) {
1717
builder.usingDevtools(Config.reduxDevtoolsUrl);

example/lib/modules/app_state.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class AppState {
1212

1313
AppState({this.status, this.todos});
1414

15-
factory AppState.fromJson(Map<String, dynamic> json) => _$AppStateFromJson(json);
15+
factory AppState.initialState() =>
16+
AppState(status: Map.unmodifiable({}), todos: List.unmodifiable([]));
17+
18+
factory AppState.fromJson(Map<String, dynamic> json) =>
19+
_$AppStateFromJson(json);
1620
Map<String, dynamic> toJson() => _$AppStateToJson(this);
1721
}

0 commit comments

Comments
 (0)