You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Which part of the Redux global state does our component want to receive on $scope?
58
+
mapStateToScope(state) {
59
+
return {
60
+
counter:state.counter
61
+
};
57
62
}
58
63
}
59
64
```
@@ -70,20 +75,18 @@ Creates the Redux store, and allow `connect()` to access it.
70
75
*[`storeEnhancers`]\(*Function[]*): Optional, this will be used to create the store, in most cases you don't need to pass anything, see [Store Enhancer official documentation.](http://rackt.github.io/redux/docs/Glossary.html#store-enhancer)
*[`mapStateToTarget`]\(*Function*): connect will subscribe to Redux store updates. Any time it updates, mapStateToTarget will be called. Its result must be a plain object, and it will be merged into `target`.
79
-
*[`target`]\(*Object*): A plain object, this will be use as a target by `mapStateToTarget`. Read the Remarks below about the implication of passing `$scope` to `connect`.
80
-
81
-
#### Returns
82
-
(*Function*): A function that unsubscribes the change listener.
83
+
*[`scope`]\(*Object*): The `$scope` of your controller.
84
+
*[`mapStateToScope`]\(*Function*): connect will subscribe to Redux store updates. Any time it updates, mapStateToTarget will be called. Its result must be a plain object, and it will be merged into `target`.
85
+
*[`mapDispatchToScope`]\(*Object* or *Function*): If an object is passed, each function inside it will be assumed to be a Redux action creator. An object with the same function names, but bound to a Redux store, will be merged into your component `$scope`. If a function is passed, it will be given `dispatch`. It’s up to you to return an object that somehow uses `dispatch` to bind action creators in your own way. (Tip: you may use the [`bindActionCreators()`](http://gaearon.github.io/redux/docs/api/bindActionCreators.html) helper from Redux.).
86
+
*[`propertyKey`]\(*string*): If provided, `mapStateToScope` and `mapDispatchToScope` will merge onto `$scope[propertyKey]`. This is needed especially when using the `ControllerAs` syntax: in this case you should provide the same value than the value provided to controllerAs (e.g: `'vm'`). When not using `ControllerAs` syntax, you are free to omit this argument, everything will be merged directly onto `$scope`.
83
87
84
88
#### Remarks
85
-
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.
86
-
If anything else than `$scope` is passed as target, the responsability to unsubscribe correctly is deferred to the user.
89
+
As `$scope` is passed to `connect`, ngRedux will listen to the `$destroy` event and unsubscribe the change listener itself, you don't need to keep track of your subscribtions.
87
90
88
91
### Store API
89
92
All of redux's store methods (i.e. `dispatch`, `subscribe` and `getState`) are exposed by $ngRedux and can be accessed directly. For example:
@@ -92,6 +95,8 @@ All of redux's store methods (i.e. `dispatch`, `subscribe` and `getState`) are e
This means that you are free to use Redux basic API in advanced cases where `connect`'s API would not fill your needs.
99
+
95
100
96
101
## Using DevTools
97
102
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.
0 commit comments