@@ -7,6 +7,19 @@ import 'package:built_value/built_value.dart';
7
7
8
8
part 'example.g.dart' ;
9
9
10
+ void main () {
11
+ // create the store
12
+ final store = new Store (
13
+ reducerBuilder.build (),
14
+ new Counter (),
15
+ new CounterActions (),
16
+ );
17
+
18
+ runApp (new ConnectionExample (store));
19
+ // or comment the line above and uncomment the line below
20
+ // runApp(new ConnectorExample(store));
21
+ }
22
+
10
23
/// an example using `StoreConnection`
11
24
class ConnectionExample extends StatelessWidget {
12
25
final Store <Counter , CounterBuilder , CounterActions > store;
@@ -61,9 +74,7 @@ class CounterWidget extends StoreConnector<Counter, CounterActions, int> {
61
74
CounterWidget ();
62
75
63
76
@override
64
- int connect (Counter state) {
65
- return state.count;
66
- }
77
+ int connect (Counter state) => state.count;
67
78
68
79
@override
69
80
Widget build (BuildContext context, int count, CounterActions actions) =>
@@ -80,13 +91,7 @@ class CounterWidget extends StoreConnector<Counter, CounterActions, int> {
80
91
);
81
92
}
82
93
83
- // Built redux counter store, actions, and reducer
84
-
85
- Store <Counter , CounterBuilder , CounterActions > createStore () => new Store (
86
- reducerBuilder.build (),
87
- new Counter (),
88
- new CounterActions (),
89
- );
94
+ // Built redux counter state, actions, and reducer
90
95
91
96
ReducerBuilder <Counter , CounterBuilder > reducerBuilder =
92
97
new ReducerBuilder <Counter , CounterBuilder >()
0 commit comments