Skip to content

Commit 095b451

Browse files
authored
Merge pull request #10 from KevinAst/next2
publish: v0.1.2 Auto Redux DevTools Integration
2 parents ecf20bd + 0317d69 commit 095b451

File tree

4 files changed

+80
-30
lines changed

4 files changed

+80
-30
lines changed

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ and **contains migration instructions**.
1111

1212
Release | What | *When*
1313
---------|-------------------------------------------------|------------------
14+
[v0.1.2] | Auto Redux DevTools Integration | *March 29, 2018*
1415
[v0.1.1] | react-native android patch | *March 7, 2018*
1516
[v0.1.0] | Initial Release | *March 6, 2018*
1617

18+
[v0.1.2]: #v012---auto-redux-devtools-integration-march-29-2018
1719
[v0.1.1]: #v011---react-native-android-patch-march-7-2018
1820
[v0.1.0]: #v010---initial-release-march-6-2018
1921

@@ -27,13 +29,41 @@ TEMPLATE:
2729
[GitHub Content](https://github.com/KevinAst/feature-redux/tree/vn.n.n)
2830
•
2931
[GitHub Release](https://github.com/KevinAst/feature-redux/releases/tag/vn.n.n)
32+
•
33+
[Diff](see below)
3034
3135
RUNNING CONTENT (pop out as needed) ...
3236
37+
- adorn bullets with following bolded prefix
38+
**Added**: ... for new features
39+
**Changed**: ... for changes in existing functionality
40+
**Deprecated**: ... for soon-to-be removed features
41+
**Removed**: ... for now removed features
42+
**Fixed**: ... for any bug fixes
43+
**Enhanced**: ... for enhancements
44+
**Security**: ... in case of vulnerabilities
45+
**Docs**: ... changes in documentation
46+
3347
UNRELEASED ******************************************************************************** -->
3448

3549

50+
<!-- *** RELEASE *************************************************************** -->
3651

52+
## v0.1.2 - Auto Redux DevTools Integration *(March 29, 2018)*
53+
54+
[GitHub Content](https://github.com/KevinAst/feature-redux/tree/v0.1.2)
55+
&bull;
56+
[GitHub Release](https://github.com/KevinAst/feature-redux/releases/tag/v0.1.2)
57+
&bull;
58+
[Diff](https://github.com/KevinAst/feature-redux/compare/v0.1.1...v0.1.2)
59+
60+
**NOTE**: This release is a **non-breaking change** _(i.e. no API was affected)_.
61+
62+
- **Enhanced**: Integration with Redux DevTools is automatically
63+
configured (when detected).
64+
65+
- **Docs**: Removed action-u reference from example code, using a more
66+
conventional "defined constant" action type.
3767

3868

3969
<!-- *** RELEASE *************************************************************** -->
@@ -43,10 +73,12 @@ UNRELEASED *********************************************************************
4373
[GitHub Content](https://github.com/KevinAst/feature-redux/tree/v0.1.1)
4474
&bull;
4575
[GitHub Release](https://github.com/KevinAst/feature-redux/releases/tag/v0.1.1)
76+
&bull;
77+
[Diff](https://github.com/KevinAst/feature-redux/compare/v0.1.0...v0.1.1?short_path=4ac32a7#diff-4ac32a78649ca5bdd8e0ba38b7006a1e)
4678

4779
**NOTE**: This release is a **non-breaking change** _(i.e. no API was affected)_.
4880

49-
- A patch was applied in support of **react-native android**.
81+
- **Fixed**: A patch was applied in support of **react-native android**.
5082

5183
When running react-native under android, receiving the following
5284
exception:

README.md

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -255,35 +255,25 @@ single-source-of-truth, however importing feature from your action
255255
modules is problematic _(the [`Feature`] object will most likely not be
256256
fully resolved during in-line code expansion)_. As a result, a **best
257257
practice** is to import a separate `featureName` constant (*that
258-
simply holds the name*). Here is an example using [action-u] (_see:
259-
`**3**` below_):
258+
simply holds the name*). Here is an example:
260259

261-
**src/feature/featureA/featureName.js**
260+
**src/feature/timer/featureName.js**
262261
```js
263-
export default 'featureA'; // **3**
262+
export default 'timer';
264263
```
265264

266-
**src/feature/featureA/actions.js**
265+
**src/feature/timer/actions.js**
267266
```js
268-
import {generateActions} from 'action-u';
269-
import featureName from './featureName';
267+
import featureName from './featureName';
270268

271-
export default generateActions.root({
272-
[featureName]: { // **3** prefix all actions with our feature name, guaranteeing uniqueness app-wide!
273-
action1: { // actions.action1(): Action
274-
actionMeta: {},
275-
},
276-
action2: { // actions.action2(): Action
277-
actionMeta: {},
278-
},
279-
etc...
280-
},
281-
});
282-
```
269+
// action type constants
270+
export const TIMER_START = `${featureName}.TIMER_START`;
271+
export const TIMER_CANCEL = `${featureName}.TIMER_CANCEL`;
272+
export const TIMER_RESET = `${featureName}.TIMER_RESET`;
273+
export const TIMER_END = `${featureName}.TIMER_END`;
283274

284-
This example results in [actions] of type:
285-
- `featureA.action1`
286-
- `featureA.action2`
275+
... snip snip
276+
```
287277

288278
</ul>
289279

@@ -496,9 +486,12 @@ this process (_i.e. the inputs and outputs_) are documented here.
496486

497487
3. **Other**:
498488

499-
For good measure, **feature-redux** promotes the [redux store]
500-
through the `Aspect.getReduxStore()` method. This provides direct
501-
access to the [store] to any external process that needs it.
489+
- For good measure, **feature-redux** promotes the [redux store]
490+
through the `Aspect.getReduxStore()` method. This provides direct
491+
access to the [store] to any external process that needs it.
492+
493+
- Integration with Redux DevTools is automatically configured (when
494+
detected).
502495

503496

504497
### Error Conditions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "feature-redux",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "feature-u redux integration",
55
"main": "lib/index.js",
66
"browser": {

src/reducerAspect.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default createAspect({
2626
config: {
2727
allowNoReducers$: false, // PUBLIC: client override to: true || [{reducerFn}]
2828
createReduxStore$, // HIDDEN: createReduxStore$(appReducer, middlewareArr): appStore
29+
reduxDevToolHook$, // HIDDEN: reduxDevToolHook$(): {enhancer$, compose$}
2930
},
3031
});
3132

@@ -202,14 +203,38 @@ function assembleAspectResources(app, aspects) {
202203
* @private
203204
*/
204205
function createReduxStore$(appReducer, middlewareArr) {
206+
// auto configure Redux DevTools (when detected)
207+
const {enhancer$, compose$} = this.reduxDevToolHook$();
208+
205209
// define our Redux app-wide store WITH optional middleware regsistration
206210
return middlewareArr.length === 0
207-
? createStore(appReducer)
208-
: createStore(appReducer,
209-
compose(applyMiddleware(...middlewareArr)));
211+
? createStore(appReducer, enhancer$) // NOTE: passing enhancer as last argument requires redux@>=3.1.0
212+
: createStore(appReducer, compose$(applyMiddleware(...middlewareArr)));
213+
}
214+
215+
216+
/**
217+
* Auto detect Redux Dev Tools when installed in browser.
218+
*
219+
* NOTE: It's OK to use Redux Dev Tools in production: http://bit.ly/rdtOkForProd
220+
*
221+
* @return {enhancer$, compose$} to be used in creating redux store.
222+
*
223+
* @private
224+
*/
225+
function reduxDevToolHook$() {
226+
const win = window || {}; // no-op in non-browser env (i.e. react-native)
227+
const extension = win.__REDUX_DEVTOOLS_EXTENSION__;
228+
const enhancer$ = extension && extension();
229+
const compose$ = win.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
230+
if (extension) {
231+
logf.force('createReduxStore$() hooking into Redux DevTools (installed in your browser)');
232+
}
233+
return {enhancer$, compose$};
210234
}
211235

212236

237+
213238
/**
214239
* Promote our redux store (for good measure), just in case some
215240
* external process needs it.

0 commit comments

Comments
 (0)