Skip to content

Commit 2ee6b0f

Browse files
committed
Update README.md
1 parent f7a1359 commit 2ee6b0f

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ For Angular 2 see [ng2-redux](https://github.com/wbuchwalter/ng2-redux).
1717
- [Installation](#installation)
1818
- [Quick Start](#quick-start)
1919
- [API](#api)
20+
- [Using DevTools](#using-devtools)
2021

2122
## Installation
2223
```js
@@ -84,9 +85,58 @@ Connects an Angular component to Redux.
8485
If `$scope` is passed to `connect` as `target`, ngRedux will listen to the `$destroy` event and unsubscribe the change listener when it is triggered, you don't need to keep track of your subscribtions in this case.
8586
If anything else than `$scope` is passed as target, the responsability to unsubscribe correctly is deferred to the user.
8687

87-
## Store API
88+
### Store API
8889
All of redux's store methods (i.e. `dispatch`, `subscribe` and `getState`) are exposed by $ngRedux and can be accessed directly. For example:
8990

9091
```JS
9192
redux.bindActionCreators(actionCreator, $ngRedux.dispatch);
9293
```
94+
95+
96+
## Using DevTools
97+
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.
98+
99+
```JS
100+
[...]
101+
import { devTools, persistState } from 'redux-devtools';
102+
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
103+
import React, { Component } from 'react';
104+
105+
angular.module('app', ['ngRedux'])
106+
.config(($ngReduxProvider) => {
107+
$ngReduxProvider.createStoreWith(rootReducer, [thunk], [devTools()]);
108+
})
109+
.run(($ngRedux, $rootScope) => {
110+
React.render(
111+
<App store={ $ngRedux }/>,
112+
document.getElementById('devTools')
113+
);
114+
115+
//To reflect state changes when disabling/enabling actions via the monitor
116+
//there is probably a smarter way to achieve that
117+
$ngRedux.subscribe(_ => {
118+
setTimeout($rootScope.$apply, 100);
119+
});
120+
});
121+
122+
class App extends Component {
123+
render() {
124+
return (
125+
<div>
126+
<DebugPanel top right bottom>
127+
<DevTools store={ this.props.store } monitor = { LogMonitor } />
128+
</DebugPanel>
129+
</div>
130+
);
131+
}
132+
}
133+
```
134+
135+
```HTML
136+
<body>
137+
<div ng-app='app'>
138+
[...]
139+
</div>
140+
<div id="devTools"></div>
141+
</body>
142+
```

0 commit comments

Comments
 (0)