Skip to content

Commit f5206a6

Browse files
authored
Merge pull request #17 from KevinAst/next7
publish: v3.0.0 Redux Enhancer Injection and Aspect Plugin Changes
2 parents 8e0146a + 3c643b6 commit f5206a6

File tree

6 files changed

+477
-133
lines changed

6 files changed

+477
-133
lines changed

CHANGELOG.md

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ and **contains migration instructions**.
99

1010
## Summary:
1111

12-
Release | What | *When*
13-
---------|-------------------------------------------------|------------------
14-
[v1.0.1] | Address Security Alerts | *December 10, 2019*
15-
[v1.0.0] | feature-u V1 Integration | *August 14, 2018*
16-
[v0.1.3] | Establish Polyfill Strategy | *July 2, 2018*
17-
[v0.1.2] | Auto Redux DevTools Integration | *March 29, 2018*
18-
[v0.1.1] | react-native android patch | *March 7, 2018*
19-
[v0.1.0] | Initial Release | *March 6, 2018*
20-
21-
12+
Release | What | *When*
13+
---------|----------------------------------------------------------|------------------
14+
[v3.0.0] | Redux Enhancer Injection and Aspect Plugin Changes | *February, 5, 2020*
15+
[v1.0.1] | Address Security Alerts | *December 10, 2019*
16+
[v1.0.0] | feature-u V1 Integration | *August 14, 2018*
17+
[v0.1.3] | Establish Polyfill Strategy | *July 2, 2018*
18+
[v0.1.2] | Auto Redux DevTools Integration | *March 29, 2018*
19+
[v0.1.1] | react-native android patch | *March 7, 2018*
20+
[v0.1.0] | Initial Release | *March 6, 2018*
21+
22+
[v3.0.0]: #v300---redux-enhancer-injection-and-aspect-plugin-changes-february-5-2020
2223
[v1.0.1]: #v101---address-security-alerts-december-10-2019
2324
[v1.0.0]: #v100---feature-u-v1-integration-august-14-2018
2425
[v0.1.3]: #v013---establish-polyfill-strategy-july-2-2018
@@ -56,6 +57,65 @@ RUNNING CONTENT (pop out as needed) ...
5657
UNRELEASED ******************************************************************************** -->
5758

5859

60+
<!-- *** RELEASE *************************************************************** -->
61+
62+
## v3.0.0 - Redux Enhancer Injection and Aspect Plugin Changes *(February, 5, 2020)*
63+
64+
[GitHub Content](https://github.com/KevinAst/feature-redux/tree/v3.0.0)
65+
&bull;
66+
[GitHub Release](https://github.com/KevinAst/feature-redux/releases/tag/v3.0.0)
67+
&bull;
68+
[Diff](https://github.com/KevinAst/feature-redux/compare/v1.0.1...v3.0.0)
69+
70+
**NOTE**: This release contains **minor breaking changes** from prior
71+
releases ... some API changes, at minimum a new version of the
72+
**feature-u** peer dependency _(also v3.0.0)_. _A trivial retrofit of
73+
client code is necessary_!
74+
75+
- Pardon the version bump (from v1.0.1 to v3.0.0).
76+
We skipped v2 strictly as an internal management convenience - to
77+
match the required peer dependency of **feature-u** _(which is also
78+
v3.0.0)_.
79+
80+
- **Added**: External Aspects may now introduce their own enhancers to
81+
the redux store through the `Aspect.getReduxEnhancer()` API _(an
82+
"aspect cross-communication mechanism")_ **... thanks
83+
[@sylvainlg](https://github.com/sylvainlg)!!**
84+
_This similar to how External Aspects have always been able to
85+
introduce their own redux middleware_.
86+
Please refer to the "Enhancer Integration"
87+
[Inputs](./README.md#inputs) section for more information.
88+
89+
- **Added**: This Aspect Plugin now promotes the redux
90+
`getState`/`dispatch` functions in the namedParams of
91+
**feature-u**'s Application Life Cycle Hooks ... see [Interface
92+
Points / Exposure](./README.md#exposure)
93+
94+
Previously, these parameters were promoted directly by
95+
**feature-u**, but that coupling has been removed in favor of a new
96+
internal mechanism allowing any Aspect to inject their namedParams.
97+
98+
As a result, this **feature-redux** release (V3) requires
99+
**feature-u** V3 or greater (and is reflected in it's **feature-u**
100+
peerDependency: `">=3.0.0"`).
101+
102+
- **Changed**: The `createReducerAspect()` creator function now
103+
accepts only named parameters ... see [API](./README.md#reduceraspect-aspect)
104+
105+
- **Added**: A new optional `initialState` parameter was introduced
106+
_(in the `createReducerAspect()` creator function)_, that provides a
107+
pre-loaded initial state of your store ... see
108+
[API](./README.md#reduceraspect-aspect)
109+
110+
- **Added**: A new optional `allowNoReducers` parameter was introduced
111+
_(in the `createReducerAspect()` creator function)_, that directs
112+
what happens when no reducers were specified on your features
113+
... see [API](./README.md#reduceraspect-aspect)
114+
115+
- **Internal**: All initialization/validation was moved from the
116+
genesis() hook into our constructor.
117+
118+
59119
<!-- *** RELEASE *************************************************************** -->
60120

61121
## v1.0.1 - Address Security Alerts *(December 10, 2019)*

README.md

Lines changed: 95 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Let's see how this all works together ...
9393
npm install --save react-redux
9494
```
9595
<!--- WITH REVEAL of USAGE:
96-
npm install --save feature-u # VER: >=1.0.0 USAGE: createAspect(), extendAspectProperty() (v1 replaces App with Fassets obj -AND- publicFace with fassets aspect)
96+
npm install --save feature-u # VER: >=3.0.0 USAGE: createAspect(), extendAspectProperty() (v1 replaces App with Fassets obj -AND- publicFace with fassets aspect)
9797
npm install --save react # VER: >=0.14.0 USAGE: inject <Provider> component
9898
npm install --save redux # VER: >=3.1.0 USAGE: applyMiddleware(), combineReducers(), compose(), createStore()
9999
npm install --save react-redux # VER: >=1.0.0 USAGE: <Provider> component
@@ -167,19 +167,20 @@ Polyfills](#potential-need-for-polyfills))_.
167167

168168
**Well that was easy!!** At this point **redux** is **completely setup
169169
for your application!** The [redux store] has been created and is
170-
accessible through the standard **redux** [`connect()`] function.
170+
accessible through the standard **redux** [`connect()`] HoC,
171+
or the newer [`Hooks`] API.
171172

172173
In the nutshell, that's a highlight of most everything you need to know to use
173174
**feature-redux**! _Go forth and compute!_
174175

175176

176177
## A Closer Look
177178

178-
**feature-redux** automatically configures [redux] by creating the [store]
179-
_(accumulating feature [reducers] across your app)_, and making the
180-
[store] available through the standard **redux** [`connect()`] function,
181-
_(by injecting the standard **redux** [`<Provider>`] component at the root
182-
of your app)_.
179+
**feature-redux** automatically configures [redux] by creating the
180+
[store] _(accumulating feature [reducers] across your app)_, and
181+
making the [store] available through the standard **redux**
182+
[`connect()`] HoC (or the newer [`Hooks`] API), _(by injecting the
183+
standard **redux** [`<Provider>`] component at the root of your app)_.
183184

184185
It is important to understand that your interface to [redux] has not
185186
changed in any way. In other words, you continue to use [redux] the
@@ -473,6 +474,13 @@ this process (_i.e. the inputs and outputs_) are documented here.
473474
mechanism"). As an example, the [feature-redux-logic] Aspect
474475
integrates **redux-logic**.
475476

477+
3. **Enhancer Integration**:
478+
479+
Because **feature-redux** manages [redux], other Aspects can
480+
promote their [redux enhancer] through **feature-redux**'s
481+
`Aspect.getReduxEnhancer()` API (an "aspect cross-communication
482+
mechanism").
483+
476484

477485
### Exposure
478486

@@ -482,16 +490,29 @@ this process (_i.e. the inputs and outputs_) are documented here.
482490
app is by injecting the standard **redux** [`<Provider>`] component at
483491
the root of your application DOM. This enables app component
484492
access to the [redux store] (along with it's `dispatch()` and
485-
`getState()`) through the standard **redux** [`connect()`] function.
493+
`getState()`) through the standard **redux** [`connect()`] HoC,
494+
or the newer [`Hooks`] API.
495+
496+
2. **Application Life Cycle Hooks - namedParams**:
486497

487-
2. **Middleware Features**:
498+
**feature-redux** promotes the redux `getState`/`dispatch`
499+
functions as namedParams of **feature-u**'s [Application Life Cycle
500+
Hooks].
501+
502+
3. **Redux Middleware**:
488503

489504
Because **feature-redux** allows other aspects to inject their
490505
[redux middleware], whatever that middleware exposes is made
491506
available. As an example, the [feature-redux-logic] Aspect
492507
injects **redux-logic**.
508+
509+
4. **Redux Enhancer**:
510+
511+
Because **feature-redux** allows other aspects to inject their
512+
[redux enhancer], whatever that enhancer exposes is made
513+
available.
493514

494-
3. **Other**:
515+
5. **Other**:
495516

496517
- For good measure, **feature-redux** promotes the [redux store]
497518
through the `Aspect.getReduxStore()` method. This provides direct
@@ -503,34 +524,36 @@ this process (_i.e. the inputs and outputs_) are documented here.
503524

504525
### Error Conditions
505526

506-
When **feature-redux** detects that no reducers have been
507-
specified by any of your features, it will (by default) throw the
508-
following exception:
527+
- **NO REDUCERS**:
509528

510-
```
511-
***ERROR*** feature-redux found NO reducers within your features
512-
... did you forget to register Feature.reducer aspects in your features?
513-
(please refer to the feature-redux docs to see how to override this behavior).
514-
```
529+
When **feature-redux** detects that no reducers have been
530+
specified by any of your features, it will (by default) throw the
531+
following exception:
515532

516-
Most likely this should in fact be considered an error _(for example
517-
you neglected to specify the reducer aspects within your features)_.
518-
**The reasoning is**: _why would you not specify any reducers if your
519-
using redux?_
533+
```
534+
***ERROR*** feature-redux found NO reducers within your features
535+
... did you forget to register Feature.reducer aspects in your features?
536+
(please refer to the feature-redux docs to see how to override this behavior).
537+
```
520538

521-
You can change this behavior through the following configuration:
539+
Most likely this should in fact be considered an error _(for example
540+
you neglected to specify the reducer aspects within your features)_.
541+
**The reasoning is**: _why would you not specify any reducers if your
542+
using redux?_
522543

523-
```js
524-
reducerAspect.config.allowNoReducers$ = true;
525-
```
544+
You can change this behavior through the `allowNoReducers` parameter:
545+
546+
```js
547+
createReducerAspect({allowNoReducers: true})
548+
```
526549

527-
With this option enabled, when no reducers are found, redux will be
528-
configured with an identity reducer (accompanied with a WARNING
529-
logging probe).
550+
- when `true`, and no reducers are found, redux will be configured
551+
with an identity reducer (accompanied with a WARNING logging
552+
probe).
530553

531-
You can also specify your own reducer function in place of the `true`
532-
value, which will be used ONLY in the scenario where no reducers were
533-
specified by your features.
554+
- you can also specify your own app-wide reducer function in place
555+
of the `true` value, which will be used ONLY in the scenario where
556+
no reducers were specified by your features.
534557

535558

536559
## API
@@ -539,12 +562,37 @@ specified by your features.
539562

540563
<ul><!--- indentation hack for github - other attempts with style is stripped (be careful with number bullets) --->
541564

542-
`API: createReducerAspect([name='reducer']): reducerAspect`
565+
```
566+
API: createReducerAspect({name:'reducer',
567+
initialState:undefined,
568+
allowNoReducers:false}): reducerAspect
569+
```
543570

544571
The `reducerAspect` is the [feature-u] plugin that facilitates
545572
[redux] integration to your features.
546573

547-
To use this aspect:
574+
**PARAMS**: _(**Please Note**: only named parameters are used)_
575+
576+
- **name**: The name of this reducer (defaults to 'reducer')
577+
578+
- **initialState**: An optional pre-loaded state that will become the initial
579+
state of your store.
580+
581+
Typically this is not needed, because your reducers will define the
582+
initial state.
583+
However, it can be useful to hydrate the state from the server (in
584+
universal apps), or to restore a previously serialized user session.
585+
586+
When supplied, any validation/errors will be detected by redux, as
587+
it is passed directly to it's `createStore()`.
588+
589+
- **allowNoReducers**: A boolean -or- app-wide reducer function, that
590+
specifies what to do when **no reducers** are found in any or your
591+
features (defaults to `false` which throws an error) ... see: **NO
592+
REDUCERS** section of [Error Conditions](#error-conditions)
593+
594+
595+
**USAGE**:
548596

549597
- Within your mainline, register the **feature-redux**
550598
`reducerAspect` to **feature-u**'s [`launchApp()`].
@@ -679,21 +727,25 @@ implemented)_ is intended to address this issue.
679727

680728

681729
<!--- redux --->
730+
682731
[redux]: https://redux.js.org/
683-
[redux store]: https://redux.js.org/docs/api/Store.html
684-
[store]: https://redux.js.org/docs/api/Store.html
685-
[redux middleware]: https://redux.js.org/docs/advanced/Middleware.html
686-
[actions]: https://redux.js.org/docs/basics/Actions.html
687-
[action creators]: https://redux.js.org/docs/basics/Actions.html#action-creators
688-
[reducers]: https://redux.js.org/docs/basics/Reducers.html
689-
[reducer]: https://redux.js.org/docs/basics/Reducers.html
732+
[redux store]: https://redux.js.org/glossary#store
733+
[store]: https://redux.js.org/glossary#store
734+
[redux middleware]: https://redux.js.org/glossary#middleware
735+
[redux enhancer]: https://redux.js.org/glossary#store-enhancer
736+
[actions]: https://redux.js.org/glossary#action
737+
[action creators]: https://redux.js.org/glossary#action-creator
738+
[reducers]: https://redux.js.org/glossary#reducer
739+
[reducer]: https://redux.js.org/glossary#reducer
690740
[selectors]: https://gist.github.com/abhiaiyer91/aaf6e325cf7fc5fd5ebc70192a1fa170
691-
[`connect()`]: https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options
692-
[`<Provider>`]: https://github.com/reactjs/react-redux/blob/master/docs/api.md#provider-store
741+
[`connect()`]: https://react-redux.js.org/api/connect
742+
[`Hooks`]: https://react-redux.js.org/api/hooks
743+
[`<Provider>`]: https://react-redux.js.org/api/provider
693744

694745
<!--- redux-logic --->
695746
[redux-logic]: https://github.com/jeffbski/redux-logic
696747

697748
<!--- 3rd party action managers --->
698749
[action-u]: https://action-u.js.org/
699750
[redux-actions]: https://github.com/reduxactions/redux-actions
751+
[Application Life Cycle Hooks]: https://feature-u.js.org/cur/appLifeCycle.html

package-lock.json

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "feature-redux",
3-
"version": "1.0.1",
3+
"version": "3.0.0",
44
"description": "feature-u redux integration",
55
"main": "lib/index.js",
66
"browser": {
@@ -89,22 +89,23 @@
8989
"eslint": "^3.19.0",
9090
"eslint-loader": "^1.7.1",
9191
"eslint-plugin-react": "^7.6.1",
92-
"feature-u": ">=1.0.0",
92+
"feature-u": "^3.0.0",
9393
"jest": "^22.1.4",
9494
"npm-run-all": "^4.0.2",
9595
"react": ">=0.14.0",
96-
"react-redux": ">=1.0.0",
9796
"react-dom": ">=16.0.1",
97+
"react-redux": ">=1.0.0",
9898
"redux": ">=3.1.0",
9999
"rimraf": "^2.6.1",
100100
"webpack": "^2.4.1"
101101
},
102102
"dependencies": {
103103
"lodash.isfunction": "^3.0.8",
104+
"lodash.isplainobject": "^4.0.6",
104105
"lodash.isstring": "^4.0.1"
105106
},
106107
"peerDependencies": {
107-
"feature-u": ">=1.0.0",
108+
"feature-u": ">=3.0.0",
108109
"react": ">=0.14.0",
109110
"redux": ">=3.1.0",
110111
"react-redux": ">=1.0.0",

0 commit comments

Comments
 (0)