Skip to content

Commit 4099327

Browse files
committed
update readme
1 parent 70bb76c commit 4099327

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Add the following script tag to your html:
4141

4242
#### Initialization
4343

44+
You can initialize ngRedux two ways:
45+
46+
Function as the reducer argument for the `createStoreWith`:
47+
4448
```JS
4549
import reducers from './reducers';
4650
import { combineReducers } from 'redux';
@@ -54,6 +58,27 @@ angular.module('app', [ngRedux])
5458
});
5559
```
5660

61+
A reducer object as reducer argument for the `createStoreWith`:
62+
63+
```JS
64+
import reducers from './reducers';
65+
import { combineReducers } from 'redux';
66+
import loggingMiddleware from './loggingMiddleware';
67+
import ngRedux from 'ng-redux';
68+
69+
angular.module('app', [ngRedux])
70+
.config(($ngReduxProvider) => {
71+
reducer3 = functtion(state, action){}
72+
$ngReduxProvider.createStoreWith({
73+
reducer1: "reducer1",
74+
reducer2: function(state, action){},
75+
reducer3: reducer3
76+
}, ['promiseMiddleware', loggingMiddleware]);
77+
});
78+
```
79+
80+
The object can be constructed either by passing a function as value or a string representing the reducer. This way, you can create reducers as services and initialze them inside the `.config`. Behind the secnes, ngRedux will `$injector.get` the string you pass as the value for the ojects of reducers and initilaze it.
81+
5782
#### Usage
5883

5984
*Using controllerAs syntax*

0 commit comments

Comments
 (0)