-
Notifications
You must be signed in to change notification settings - Fork 131
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
Iron list does not re-render a mutated item #504
Comments
+1 any update here? |
This seems to have broken in 2.x, in 1.x it worked fine. Not responding to data updates seems like a fundamental problem for many applications. Is this being investigated? Note the .set('items.5', itemClone) workaround doesn't seem to work for me too. |
Does calling the private method Another way to workaround these mutability issues is to use immutable objects/arrays. That is, construct new objects/arrays when |
This does not work in Polymer iron list as it should. Please look at the first comment. There is a severe caching problem.
|
I meant immutability at all levels - this means a deep copy of the oldList array (e.g. a new object for every changed index). list = [
...oldList.slice(0, i),
{
...oldObjAtI,
changedProp
},
...oldList.slice(i+1)
]; This is because equality operators are still used within iron-list for each item to determine when to re-render. |
I have used react before, and adapted to the mutability issues; This component takes it to a whole new level though.
As mentioned in the first post, an invalidate method should be part of the public API. When it works, it works GREAT though ;) |
@Flamenco did you figure it out? A demo/example would be great - I tried the fixed suggested above and nothing seems to work. |
and trying to update class in the
|
@NicolasRannou Did you set set mutableData = true on your list? |
on the list itself, on the |
The iron list. |
Hmmm no success on that... odd... To clarify, you use this approach to update a property of one object of the list:
|
I think I used the polymer data api to update the data in the list, with the new immutable object
|
Description
If I change a field in a object of my list, the iron list does not update my template. The only way I can get it to update is by calling Object.assign({}, myObject) and then either splicing or setting the cloned item via the array manipulation API.
I can set mutableData = true on my the iron-list, and get everything working, but I would like to see the data manipulation work when that is not set however.
This works:
I am aware of the mutability issues with the framework but I think this should be enough to trigger a refresh:
element.set('theList.5.foo', bar)
One issue I see is that _itemsChanged: function(change) does not receive the full path to the mutation, only the list. That makes it difficult to detect that an item was modified but still the same object...
Furthermore, the old item is sometimes cached so if I clear the list, then reload it, iron-list still uses the old value, even if I make a new copy of the list.
At the very least, iron-list should allow me to manually invalidate/flush/refresh an object in the list by index or object. IMO both the Polymer array mutation and iron-list API should provide means to indicate an object has changed.
For the record, these also do not work
The text was updated successfully, but these errors were encountered: