tur-nr / polymer-redux

Polymer bindings for Redux.
https://tur-nr.github.io/polymer-redux
MIT License
440 stars 67 forks source link

ready() does not have default properties set #115

Closed ergo closed 6 years ago

ergo commented 6 years ago

Hello,

consider following element configuration:

class FooElem extends ReduxMixin(Polymer.Element) {

static get is() {
    return 'foo-bar';
}

static get properties() {
    return {
        nonExistingInReady: {
            type: Array,
            statePath: 'currentActions'
        },
        existingInReady: {
            type: String,
            value: function(){ return 'test'}
        }
    };
}`

when doing something like:

ready() {
    super.ready();
    // refresh data when document is attached to dom
    console.log(this.existingInReady);
    console.log(this.nonExistingInReady);
}

first log will have 'testing' , second one will be undefined. the same code launched in connectedCallback will return the right value for nonExistingInReady from redux store.

It seems that this is because the defaults are set here in https://github.com/tur-nr/polymer-redux/blob/master/src/index.js#L142 , and ready is fired before connectedCallback - polymer by default does set its own propertied at this time.

tur-nr commented 6 years ago

Should be fixed whenever #123 is merged. Sorry for the wait.