|
| 1 | +## 7.3.3 |
| 2 | + |
| 3 | +* add changelog |
| 4 | +* update readme to include link to todoMVC repo |
| 5 | + |
| 6 | +## 7.3.2 |
| 7 | + |
| 8 | +* open dependency range on the build package |
| 9 | + |
| 10 | +## 7.3.1 |
| 11 | + |
| 12 | +* open dependency range on the built_collection package |
| 13 | + |
| 14 | +## 7.3.0 |
| 15 | + |
| 16 | +* dispose is now awaitable |
| 17 | + |
| 18 | +## 7.2.0 |
| 19 | + |
| 20 | +* Added actionStream stream to the store api so one can listen to changes resulting from a specific action name. |
| 21 | +* Fixed issues called out my adding implicit-dynamic and implicit-cast rules. |
| 22 | + |
| 23 | +## 7.1.0 |
| 24 | + |
| 25 | +* Added reducer builders for all collection types in built_collection. This means you can now write reducers that rebuild just a collection. Examples: https://github.com/davidmarne/built_redux/blob/master/test/unit/collection_models.dart |
| 26 | +* The action generator now supports inheritance, meaning one can now have action classes extend one another. AbstractReducerBuilder was added as means of merging a reducer builder defined to rebuild the abstract pieces of state. Examples: https://github.com/davidmarne/built_redux/blob/7.1.0/test/unit/inheritance_test_models.dart for examples |
| 27 | + |
| 28 | +## 7.0.0 |
| 29 | + |
| 30 | +* **Breaking changes**: |
| 31 | + * A breaking change in behavior was made to action dispatchers. Before action dispatchers executed the middleware/reducers asynchronously, but they now execute synchronously. |
| 32 | + |
| 33 | +For example you may have: |
| 34 | + |
| 35 | +```dart |
| 36 | +int getCount(store) { |
| 37 | + print(store.state.count); // prints 0 |
| 38 | + store.actions.increment(1); |
| 39 | + print(store.state.count); // would print 1 if actions were sync, 0 if async |
| 40 | + return store.state.count; // would return 1 if actions were sync, 0 if async |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +Before this function would return 0 because the state update that occurs from actions.increment would be processed in a future task. |
| 45 | +Now this function will return 1 because the state update that occurs from actions.increment is processed in the current task |
| 46 | + |
| 47 | +## 6.0.0 |
| 48 | + |
| 49 | +Removes the BuiltReducer interface and the generated BuiltReducer implementation in favor of building a reducer function and passing it to the store at instantiation. |
| 50 | + |
| 51 | +* **Breaking changes**: |
| 52 | + * Store now takes a reducer |
| 53 | + * Nested reducers need to be built with the NestedReducerBuilder and merged wth the main ReducerBuilder using ReducerBuilder.addNestedReducer |
| 54 | + * Models no longer implement BuiltReducer |
| 55 | + * Remove references to the reducer on your models |
| 56 | + * Renamed ActionDispatcher.syncWithStore to setDispatcher |
| 57 | + * Renamed SubStateChange to SubstateChange |
| 58 | + |
| 59 | + |
| 60 | +Reasoning: |
| 61 | + |
| 62 | +* Decouples your models and reducers. |
| 63 | +* Requires less generated code. |
| 64 | +* Reducing requires less map look ups. Previously N map look ups were required where N was the number of BuiltReducers in your state tree. Now only 1 map look up is required per action dispatched. |
| 65 | + |
| 66 | + |
| 67 | +Examples: |
| 68 | + |
| 69 | +* Example model change. Remove the generated BuiltReducer mixin and the reducer getter |
| 70 | + |
| 71 | +Before: |
| 72 | + |
| 73 | +```dart |
| 74 | + abstract class Counter extends Object |
| 75 | + with CounterReducer |
| 76 | + implements Built<Counter, CounterBuilder> { |
| 77 | + int get count; |
| 78 | +
|
| 79 | + get reducer => _reducer; |
| 80 | +
|
| 81 | + Counter._(); |
| 82 | + factory BaseCounter() => new _$BaseCounter._(count: 1); |
| 83 | + } |
| 84 | +``` |
| 85 | + |
| 86 | +After: |
| 87 | + |
| 88 | +```dart |
| 89 | + abstract class Counter implements Built<Counter, CounterBuilder> { |
| 90 | + int get count; |
| 91 | +
|
| 92 | + Counter._(); |
| 93 | + factory BaseCounter() => new _$BaseCounter._(count: 1); |
| 94 | + } |
| 95 | +``` |
| 96 | + |
| 97 | +* Example nested reducer change. Change NestedCounter's reducer builder to a NestedReducerBuilder. Pass the NestedReducerBuilder mapper functions from the main state/builder to the nested state/builder. |
| 98 | + |
| 99 | +Before |
| 100 | + |
| 101 | +```dart |
| 102 | +
|
| 103 | +// Built Reducer |
| 104 | +abstract class BaseCounter extends Object |
| 105 | + with BaseCounterReducer |
| 106 | + implements Built<BaseCounter, BaseCounterBuilder> { |
| 107 | + int get count; |
| 108 | +
|
| 109 | + BuiltList<int> get indexOutOfRangeList; |
| 110 | +
|
| 111 | + NestedCounter get nestedCounter; |
| 112 | +
|
| 113 | + @override |
| 114 | + get reducer => _baseReducer; |
| 115 | +
|
| 116 | + // Built value constructor |
| 117 | + BaseCounter._(); |
| 118 | + factory BaseCounter() => new _$BaseCounter._( |
| 119 | + count: 1, |
| 120 | + nestedCounter: new NestedCounter(), |
| 121 | + ); |
| 122 | +} |
| 123 | +
|
| 124 | +final _baseReducer = (new ReducerBuilder<BaseCounter, BaseCounterBuilder>() |
| 125 | + ..add(BaseCounterActionsNames.increment, _baseIncrement) |
| 126 | + ..add(BaseCounterActionsNames.decrement, _baseDecrement)) |
| 127 | + .build(); |
| 128 | +
|
| 129 | +abstract class NestedCounter extends Object |
| 130 | + with NestedCounterReducer |
| 131 | + implements Built<NestedCounter, NestedCounterBuilder> { |
| 132 | + int get count; |
| 133 | +
|
| 134 | + get reducer => _nestedReducer; |
| 135 | +
|
| 136 | + // Built value constructor |
| 137 | + NestedCounter._(); |
| 138 | + factory NestedCounter() => new _$NestedCounter._(count: 1); |
| 139 | +} |
| 140 | +
|
| 141 | +final _nestedReducer = (new ReducerBuilder<NestedCounter, NestedCounterBuilder>() |
| 142 | + ..add(NestedCounterActionsNames.increment, _nestedIncrement) |
| 143 | + ..add(NestedCounterActionsNames.decrement, _nestedDecrement)) |
| 144 | + .build(); |
| 145 | +
|
| 146 | +``` |
| 147 | + |
| 148 | +After |
| 149 | + |
| 150 | +```dart |
| 151 | +abstract class BaseCounter implements Built<BaseCounter, BaseCounterBuilder> { |
| 152 | + int get count; |
| 153 | +
|
| 154 | + NestedCounter get nestedCounter; |
| 155 | +
|
| 156 | + BaseCounter._(); |
| 157 | + factory BaseCounter() => new _$BaseCounter._( |
| 158 | + count: 1, |
| 159 | + nestedCounter: new NestedCounter(), |
| 160 | + ); |
| 161 | +} |
| 162 | +
|
| 163 | +// the reducer passed to the store |
| 164 | +final reducer = (new ReducerBuilder<BaseCounter, BaseCounterBuilder>() |
| 165 | + ..add(BaseCounterActionsNames.increment, _baseIncrement) |
| 166 | + ..add(BaseCounterActionsNames.decrement, _baseDecrement) |
| 167 | + ..combineNested(_nestedReducer)) |
| 168 | + .build(); |
| 169 | +
|
| 170 | +abstract class NestedCounter implements Built<NestedCounter, NestedCounterBuilder> { |
| 171 | + int get count; |
| 172 | +
|
| 173 | + // Built value constructor |
| 174 | + NestedCounter._(); |
| 175 | + factory NestedCounter() => new _$NestedCounter._(count: 1); |
| 176 | +} |
| 177 | +
|
| 178 | +final _nestedReducer = new NestedReducerBuilder<BaseCounter, BaseCounterBuilder, |
| 179 | + NestedCounter, NestedCounterBuilder>( |
| 180 | + (state) => state.nestedCounter, |
| 181 | + (builder) => builder.nestedCounter, |
| 182 | +) |
| 183 | + ..add(NestedCounterActionsNames.increment, _nestedIncrement) |
| 184 | + ..add(NestedCounterActionsNames.decrement, _nestedDecrement); |
| 185 | +``` |
0 commit comments