@@ -21,13 +21,13 @@ abstract class FluxUiProps<ActionsT, StoresT> extends UiProps {
21
21
ActionsT get actions => props[_actionsPropKey] as ActionsT ; // ignore: avoid_as
22
22
set actions (ActionsT value) => props[_actionsPropKey] = value;
23
23
24
- /// The prop defined by [StoresT] .
24
+ /// The prop defined by [StoresT] . This object should either be an
25
+ /// instance of [Store] or should provide access to one or more [Store] s.
25
26
///
26
- /// This object should either be an instance of [Store] or should provide access to one or more [Store] s.
27
- ///
28
- /// __Instead of storing state within this component via `setState` , it is recommended that data be
29
- /// pulled directly from these stores.__ This ensures that the data being used is always up to date
30
- /// and leaves the state management logic to the stores.
27
+ /// **Instead of storing state within this component via [setState] , it is
28
+ /// recommended that data be pulled directly from these stores.** This ensures
29
+ /// that the data being used is always up to date and leaves the state
30
+ /// management logic to the stores.
31
31
///
32
32
/// If this component only needs data from a single [Store] , then [StoresT]
33
33
/// should be an instance of [Store] . This allows the default implementation
@@ -36,30 +36,28 @@ abstract class FluxUiProps<ActionsT, StoresT> extends UiProps {
36
36
/// If this component needs data from multiple [Store] instances, then
37
37
/// [StoresT] should be a class that provides access to these multiple stores.
38
38
/// Then, you can explicitly select the [Store] instances that should be
39
- /// listened to by overriding [_FluxComponentMixin. redrawOn] .
39
+ /// listened to by overriding [redrawOn] .
40
40
StoresT get store => props[_storePropKey] as StoresT ; // ignore: avoid_as
41
41
set store (StoresT value) => props[_storePropKey] = value;
42
42
}
43
43
44
44
/// Builds on top of [UiComponent] , adding w_flux integration, much like the [FluxComponent] in w_flux.
45
45
///
46
- /// * Flux components are responsible for rendering application views and turning
47
- /// user interactions and events into [Action] s.
48
- /// * Flux components can use data from one or many [Store] instances to define
49
- /// the resulting component.
46
+ /// Flux components are responsible for rendering application views and turning
47
+ /// user interactions and events into [Action] s. Flux components can use data
48
+ /// from one or many [Store] instances to define the resulting component.
50
49
///
51
- /// Use with the over_react transformer via the `@Component()` ([annotations. Component] ) annotation.
50
+ /// Use with the over_react transformer via the `@Component()` ([Component] ) annotation.
52
51
abstract class FluxUiComponent <TProps extends FluxUiProps > extends UiComponent <TProps >
53
52
with _FluxComponentMixin <TProps >, BatchedRedraws {}
54
53
55
- /// Builds on top of [UiStatefulComponent ] , adding ` w_flux` integration, much like the [FluxComponent] in w_flux.
54
+ /// Builds on top of [StatefulUiComponent ] , adding w_flux integration, much like the [FluxComponent] in w_flux.
56
55
///
57
- /// * Flux components are responsible for rendering application views and turning
58
- /// user interactions and events into [Action] s.
59
- /// * Flux components can use data from one or many [Store] instances to define
60
- /// the resulting component.
56
+ /// Flux components are responsible for rendering application views and turning
57
+ /// user interactions and events into [Action] s. Flux components can use data
58
+ /// from one or many [Store] instances to define the resulting component.
61
59
///
62
- /// Use with the over_react transformer via the `@Component()` ([annotations. Component] ) annotation.
60
+ /// Use with the over_react transformer via the `@Component()` ([Component] ) annotation.
63
61
abstract class FluxUiStatefulComponent <TProps extends FluxUiProps , TState extends UiState >
64
62
extends UiStatefulComponent <TProps , TState >
65
63
with _FluxComponentMixin <TProps >, BatchedRedraws {}
@@ -70,19 +68,15 @@ abstract class FluxUiStatefulComponent<TProps extends FluxUiProps, TState extend
70
68
abstract class _FluxComponentMixin <TProps extends FluxUiProps > implements BatchedRedraws {
71
69
TProps get props;
72
70
73
- /// List of store subscriptions created when the component mounts.
74
- ///
75
- /// These subscriptions are canceled when the component is unmounted.
71
+ /// List of store subscriptions created when the component mounts. These
72
+ /// subscriptions are canceled when the component is unmounted.
76
73
List <StreamSubscription > _subscriptions = [];
77
74
78
- void componentWillMount () {
79
- /// Subscribe to all applicable stores.
80
- ///
81
- /// [Store] s returned by [redrawOn] will have their triggers mapped directly to this components
82
- /// redraw function.
83
- ///
84
- /// [Store] s included in the [getStoreHandlers] result will be listened to and wired up to their
85
- /// respective handlers.
75
+ componentWillMount () {
76
+ // Subscribe to all applicable stores. Stores returned by `redrawOn()` will
77
+ // have their triggers mapped directly to this components redraw function.
78
+ // Stores included in the `getStoreHandlers()` result will be listened to
79
+ // and wired up to their respective handlers.
86
80
Map <Store , StoreHandler > handlers = new Map .fromIterable (redrawOn (),
87
81
value: (_) => (_) => redraw ())..addAll (getStoreHandlers ());
88
82
@@ -92,8 +86,8 @@ abstract class _FluxComponentMixin<TProps extends FluxUiProps> implements Batche
92
86
});
93
87
}
94
88
95
- void componentWillUnmount () {
96
- // Ensure that unmounted components don't batch render
89
+ componentWillUnmount () {
90
+ // ensure that unmounted components don't batch render
97
91
shouldBatchRedraw = false ;
98
92
99
93
// Cancel all store subscriptions.
@@ -105,7 +99,6 @@ abstract class _FluxComponentMixin<TProps extends FluxUiProps> implements Batche
105
99
}
106
100
107
101
/// Define the list of [Store] instances that this component should listen to.
108
- ///
109
102
/// When any of the returned [Store] s update their state, this component will
110
103
/// redraw.
111
104
///
@@ -128,9 +121,8 @@ abstract class _FluxComponentMixin<TProps extends FluxUiProps> implements Batche
128
121
}
129
122
130
123
/// If you need more fine-grained control over store trigger handling,
131
- /// override this method to return a Map of stores to handlers.
132
- ///
133
- /// Whenever a store in the returned map triggers, the respective handler will be called.
124
+ /// override this method to return a Map of stores to handlers. Whenever a
125
+ /// store in the returned map triggers, the respective handler will be called.
134
126
///
135
127
/// Handlers defined here take precedence over the [redrawOn] handling.
136
128
/// If possible, however, [redrawOn] should be used instead of this in order
@@ -140,9 +132,9 @@ abstract class _FluxComponentMixin<TProps extends FluxUiProps> implements Batche
140
132
return {};
141
133
}
142
134
143
- /// Register a [subscription] that should be canceled when the component unmounts.
144
- ///
145
- /// Cancellation will be handled automatically by [componentWillUnmount] .
135
+ /// Register a [subscription] that should be canceled when the component
136
+ /// unmounts. Cancellation will be handled automatically by
137
+ /// [componentWillUnmount] .
146
138
void addSubscription (StreamSubscription subscription) {
147
139
_subscriptions.add (subscription);
148
140
}
0 commit comments