ember-redux
Advanced tools
Comparing version 1.9.2 to 1.10.0
@@ -11,4 +11,8 @@ import Ember from 'ember'; | ||
export default (stateToComputed=() => ({}), dispatchToActions=() => ({})) => { | ||
export default (stateToComputed, dispatchToActions=() => ({})) => { | ||
if (!stateToComputed) { | ||
stateToComputed = () => ({}); | ||
} | ||
return Component => { | ||
@@ -23,7 +27,7 @@ | ||
let props = stateToComputed(redux.getState()); | ||
let props = stateToComputed(redux.getState(), this.getAttrs()); | ||
Object.keys(props).forEach(name => { | ||
defineProperty(this, name, computed(() => | ||
stateToComputed(redux.getState())[name] | ||
stateToComputed(redux.getState(), this.getAttrs())[name] | ||
).property().readOnly()); | ||
@@ -34,3 +38,3 @@ }); | ||
this.unsubscribe = redux.subscribe(() => { | ||
run(() => this.handleChange()); | ||
this.handleChange(); | ||
}); | ||
@@ -49,11 +53,42 @@ } | ||
let props = stateToComputed(redux.getState()); | ||
const props = stateToComputed(redux.getState(), this.getAttrs()); | ||
Object.keys(props).forEach(name => { | ||
if (this.get(name) !== props[name]) { | ||
this.notifyPropertyChange(name); | ||
} | ||
const notifyProperties = Object.keys(props).filter(name => { | ||
return this.get(name) !== props[name]; | ||
}); | ||
if (notifyProperties.length > 0) { | ||
run.join(() => { | ||
notifyProperties.forEach(name => this.notifyPropertyChange(name)); | ||
}); | ||
} | ||
}, | ||
/** | ||
* Return an object of attrs passed to this Component. | ||
* | ||
* `Component.attrs` is an object that can look like this: | ||
* | ||
* { | ||
* myAttr: { | ||
* value: 'myValue' | ||
* } | ||
* } | ||
* | ||
* Ember provides that a `get` will return the value: | ||
* | ||
* this.get('myAttr') === 'myValue' | ||
* | ||
* @method getAttrs | ||
* @private | ||
*/ | ||
getAttrs() { | ||
return this.getProperties(Object.keys(this.attrs || {})); | ||
}, | ||
didUpdateAttrs() { | ||
this._super(...arguments); | ||
this.handleChange(); | ||
}, | ||
willDestroy() { | ||
@@ -60,0 +95,0 @@ this._super(...arguments); |
ember-redux Changelog | ||
============================== | ||
1.10.0 | ||
----- | ||
* [DEPENDENCY]: upgraded to ember-cli@2.10 | ||
([#66](https://github.com/toranb/ember-redux/pull/66)) | ||
* [PERFORMANCE]: Reduce the number of run loops created when state changes | ||
([#69](https://github.com/toranb/ember-redux/pull/69)) | ||
* [TESTS]: improved runloop testing to confirm both run/and run.join work | ||
([#70](https://github.com/toranb/ember-redux/pull/70)) | ||
* [BUILD]: Alphabetize dependencies | ||
([#62](https://github.com/toranb/ember-redux/pull/62)) | ||
* [BUG]: Allow `null` stateToComputed argument | ||
([#67](https://github.com/toranb/ember-redux/pull/67)) | ||
* [FEATURE] pass attrs to stateToComputed | ||
([#56](https://github.com/toranb/ember-redux/pull/56)) | ||
1.9.2 | ||
@@ -5,0 +27,0 @@ ----- |
{ | ||
"name": "ember-redux", | ||
"version": "1.9.2", | ||
"version": "1.10.0", | ||
"description": "ember-cli addon that provides simple redux bindings for ember.js", | ||
@@ -16,7 +16,7 @@ "directories": { | ||
"bugs": { | ||
"url": "https://github.com/toranb/ember-redux/issues" | ||
"url": "https://github.com/toranb/ember-redux/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/toranb/ember-redux" | ||
"type": "git", | ||
"url": "https://github.com/toranb/ember-redux" | ||
}, | ||
@@ -29,7 +29,5 @@ "engines": { | ||
"devDependencies": { | ||
"ember-cli": "2.9.1", | ||
"ember-resolver": "^2.0.3", | ||
"loader.js": "^4.0.10", | ||
"broccoli-asset-rev": "^2.4.5", | ||
"ember-browserify": "^1.1.11", | ||
"ember-cli": "2.10.0", | ||
"ember-cli-app-version": "^2.0.0", | ||
@@ -40,15 +38,17 @@ "ember-cli-dependency-checker": "^1.3.0", | ||
"ember-cli-inject-live-reload": "^1.4.1", | ||
"ember-cli-jshint": "^1.0.4", | ||
"ember-cli-jshint": "^2.0.1", | ||
"ember-cli-qunit": "^3.0.1", | ||
"ember-cli-release": "0.2.9", | ||
"ember-cli-release": "^0.2.9", | ||
"ember-cli-sri": "^2.1.0", | ||
"ember-cli-test-loader": "^1.1.0", | ||
"ember-cli-uglify": "^1.2.0", | ||
"ember-export-application-global": "^1.0.5", | ||
"ember-load-initializers": "^0.5.1", | ||
"ember-cli-test-loader": "^1.1.0", | ||
"ember-maybe-import-regenerator": "0.1.4", | ||
"ember-resolver": "^2.0.3", | ||
"ember-try": "0.1.3", | ||
"loader.js": "^4.0.10", | ||
"redux": "^3.5.2", | ||
"redux-thunk": "^2.1.0", | ||
"ember-maybe-import-regenerator": "0.1.4", | ||
"redux-saga": "0.12.0" | ||
"redux-saga": "0.12.0", | ||
"redux-thunk": "^2.1.0" | ||
}, | ||
@@ -55,0 +55,0 @@ "keywords": [ |
@@ -34,6 +34,7 @@ # Ember Redux | ||
import ajax from 'example/utilities/ajax'; | ||
import getUsersByAccountId from '../reducers'; | ||
var stateToComputed = (state) => { | ||
var stateToComputed = (state, attrs) => { | ||
return { | ||
users: state.users.all | ||
users: getUsersByAccountId(state, attrs.accountId) | ||
}; | ||
@@ -77,3 +78,3 @@ }; | ||
```js | ||
{{#user-list as |users remove|}} | ||
{{#user-list accountId=accountId as |users remove|}} | ||
{{user-table users=users remove=remove}} | ||
@@ -80,0 +81,0 @@ {{/user-list}} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16462
181
122