From 439a96b4f06914647ff059508419db0ee031f55a Mon Sep 17 00:00:00 2001 From: cchristmas Date: Mon, 19 Dec 2016 13:09:17 -0500 Subject: [PATCH] Updated the documentation so that it doesn't throw the exception any time the state is changed anymore and added documentation for using Redux DevTools Extension instead of including react. --- README.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e4b254..9301d79 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,11 @@ See [redux-ui-router](https://github.com/neilff/redux-ui-router) to make ng-redu See [ng-redux-router](https://github.com/amitport/ng-redux-router) to make ng-redux and angular-route work together. ## Using DevTools -In order to use Redux DevTools with your angular app, you need to install [react](https://www.npmjs.com/package/react), [react-redux](https://www.npmjs.com/package/react-redux) and [redux-devtools](https://www.npmjs.com/package/redux-devtools) as development dependencies. +There are two options for using Redux DevTools with your angular app. The first option is to use the [redux-devtools package] (https://www.npmjs.com/package/redux-devtools), +and the other option is to use the [Redux DevTools Extension] (https://github.com/zalmoxisus/redux-devtools-extension#usage). The Redux DevTools Extension does not +require adding the react, react-redux, or redux-devtools packages to your project. + +To use the redux-devtools package, you need to install [react](https://www.npmjs.com/package/react), [react-redux](https://www.npmjs.com/package/react-redux) and [redux-devtools](https://www.npmjs.com/package/redux-devtools) as development dependencies. ```JS [...] @@ -203,7 +207,7 @@ angular.module('app', ['ngRedux']) .config(($ngReduxProvider) => { $ngReduxProvider.createStoreWith(rootReducer, [thunk], [devTools()]); }) - .run(($ngRedux, $rootScope) => { + .run(($ngRedux, $rootScope, $timeout) => { React.render( , document.getElementById('devTools') @@ -211,8 +215,8 @@ angular.module('app', ['ngRedux']) //To reflect state changes when disabling/enabling actions via the monitor //there is probably a smarter way to achieve that - $ngRedux.subscribe(_ => { - setTimeout($rootScope.$apply, 100); + $ngRedux.subscribe(() => { + $timeout(() => {$rootScope.$apply(() => {})}, 100); }); }); @@ -238,5 +242,21 @@ angular.module('app', ['ngRedux']) ``` +To use the Redux DevTools extension, you must first make sure that you have installed the [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension#installation). + +```JS +angular.module('app', ['ngRedux']) + .config(($ngReduxProvider) => { + $ngReduxProvider.createStoreWith(rootReducer, [thunk], [window.__REDUX_DEVTOOLS_EXTENSION__()]); + }) + .run(($ngRedux, $rootScope, $timeout) => { + //To reflect state changes when disabling/enabling actions via the monitor + //there is probably a smarter way to achieve that + $ngRedux.subscribe(() => { + $timeout(() => {$rootScope.$apply(() => {})}, 100); + }); + }); +``` + ## Additional Resources * [Managing state with Redux and Angular](http://blog.rangle.io/managing-state-redux-angular/)