Problem: we're using redux to manage state in our app. This is causing issues in the rendering. Changes in arrays (f.e. remove) are not correctly handled by the dom-repeater. What happens is that data and the stamped-templates are getting mixed up.
I want to find a way to notify dom-repeat element about array changes.
<template is="dom-repeat" items="[[data.items]]">
<repeater-item config="[[item]]" on-change="_onChange"></repeater-item>
</template>
I have immutable state in my Polymer application so I can not use Polymer array mutation methods.
What have I tried:
1) this.set('data', newState);
As a result if I will remove the first item in my data array 'dom-repeat' will remove the last template <repeater-item> and will reassign data like this:
template-1 receives data 2,
template-2 receives data 3,
...
2) in second attempt I'm trying to notifySplices:
var splices = Polymer.ArraySplice.calculateSplices(newState.items, this.data.items);
this.data = newState;
this.notifySplices('data.items', splices);
result is the same
3) For some reason the following almost works..
var splices = Polymer.ArraySplice.calculateSplices(newState.items, this.data.items);
this.data.items = newState.items;
this.notifySplices('data.items', splices);
this results in a correct template removal but here I receive an error:
VM47184 polymer-mini.html:2046 Uncaught TypeError: Cannot read property 'length' of undefined
What is the correct way of notifying 'dom-repeat' if using immutable state?