File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ For Angular 2 see [ng2-redux](https://github.com/wbuchwalter/ng2-redux).
1515- [ Installation] ( #installation )
1616- [ Quick Start] ( #quick-start )
1717- [ API] ( #api )
18+ - [ Dependency Injectable Middleware] ( #dependency-injectable-middleware )
1819- [ Routers] ( #routers )
1920- [ Using DevTools] ( #using-devtools )
2021- [ Additional Resources] ( #additional-resources )
@@ -137,6 +138,27 @@ $ngRedux.subscribe(() => {
137138
138139This means that you are free to use Redux basic API in advanced cases where ` connect ` 's API would not fill your needs.
139140
141+ ## Dependency Injectable Middleware
142+ You can use angularjs dependency injection mechanism to resolve dependencies inside a ` middleware ` .
143+ To do so, define a factory returning a middleware:
144+
145+ ``` Javascript
146+ function myInjectableMiddleware ($http , anotherDependency ) {
147+ return store => next => action => {
148+ // middleware's code
149+ }
150+ }
151+
152+ angular .factory (' myInjectableMiddleware' , myInjectableMiddleware);
153+ ```
154+
155+ And simply register your middleware during store creation:
156+
157+ ``` Javascript
158+ $ngReduxProvider .createStoreWith (reducers, [thunk, ' myInjectableMiddleware' ]);
159+ ```
160+
161+ Middlewares passed as ** string** will then be resolved throught angular's injector.
140162
141163## Routers
142164See [ redux-ui-router] ( https://github.com/neilff/redux-ui-router ) to make ng-redux and UI-Router work together. <br >
You can’t perform that action at this time.
0 commit comments