-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redux state array bound to dom-repeat doesn't reflect items property changes. #103
Comments
Plus one this issue. I am facing the same problem. sub properties are not notified on change. |
I am facing the same issue. The data is definitely updating and observers are firing ... but nothing is happening inside the dom-template. static get observers() {
return [
'_test(myArray.*)',
];
}
_test(change) {
// this all works ...
console.info(change);
console.info(this.get('myArray.0.items.length'));
} |
For reasons beyond my understanding, this seems to trigger something to make the dom-repeat update static get observers() {
return [
'_updateNotifier(myArray.*)',
];
}
_updateNotifier(change) {
change.base.forEach((base, i) => {
this.notifyPath(`${change.path}.${i}.items.length`);
});
} |
I had the same problem and @pixelass "fixed" it by using https://github.com/kolodny/immutability-helper instead of dealing with state changes on our own (even when we thought that we are creating immutable data): const myArray = [{ name: 'foo' }, { name: 'bar' }]
const newMyArray = update(myArray, { 0: { $set: { name: 'foobar' } } }) Note: We are using Polymer 3 and https://github.com/tur-nr/polymer-redux/tree/polymer-3 and https://github.com/NERDDISCO/immutability-helper/ because of ES6 modules |
On Polymer 2 there is another solution. It's to use "mutable-data" in the template dom-repeat.
The problem i found is to notify changes to children elements of the dom-repeat. Like this:
In this case
I dont know the performance of this solution. (Worried because with any minimal change in the array causes a notification of change in all the items in the dom-repeat, even if only has changed one of them) |
This worked perfect for me with immutable-js/redux, including only rending the items that have changed. FYI, I'm using Polymer 3 You need to implement helper methods for calling the immutable methods. I implemented them it as a mixin for obvious reasons....
You then use these in your template to dynamically generate a shallow JS array from the immutable list, and use
I'm probably going to do a starter project that includes this code. |
This starter project gives an example https://github.com/zakkudo/polymer-3-starter-project |
I have the following element the issue is when changing an employee thru redux action, the changes does not propagate to the dom-repeat, but is reflected when bound directly inside the parent template (e.g. [[employees.0.id]])
I've tried manual re-render of the dom-repeat template e.g. this.$.employees.render() but still does not reflect the updated employee properties
any suggestion?
Note: i'm using v1.01
Now inside the redux store actions, (i've already tried multiple ways to update the array e.g. splice)
The text was updated successfully, but these errors were encountered: