Skip to content

this.state not preserved for resuming in this.async() #36

@didrocks

Description

@didrocks

First, thanks for the codelab-components! It's awesome and really useful to have opensourced this :)

I'm having an issue with resume not fired up. Adding some debug, I observed that this.state doesn't keep the same value in _stateLoaded before and after this.async() call.

I added some debug logs in _stateLoaded:

      _stateLoaded: function() {
        console.log("State loaded: " + this.state.stepIndex)
        // allow everything render and initialize,
        // especially this.steps which runs at the same init level
        // as iron-localstorage (on attached).
        this.async(function() {
          console.log("Resume check: " + this.state.stepIndex)
          […]
        }, 500);
      },

So, here is what I'm seeing, on page load:

State loaded: 2
Resume check: 0

As you can see, this.state.stepIndex has changed. This is due to _selectedChanged being fired in between due to steps being initialized on attach.

One way could be to prevent the this.set('state.stepIndex', this.selected); assignement on attach via a loading variable, do you think of a better fix? (It sounds wrong to change this.selected, as resume isn't selected at this point).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions