Skip to content

polymer-localstorage-load only fires if the value has previously been set #404

Description

@balupton

I have this code:

<polymer-localstorage name="my-name" value="{{myName}}" polymer-localstorage-load="{{getName}}"></polymer-localstorage>
getName: function(){
                while ( !me.myName ) {
                    me.myName = prompt('What is your name?');
                }
            },

But getName never fires if the local storage value hasn't been already set. I would expect that getName always fires, as soon as the value has been fetched, even if the value is undefined.

As originally I had the following in the ready event:

                while ( !me.myName ) {
                    me.myName = prompt('What is your name?');
                }

But the localstorage element hadn't fetched the value yet, so I tried to use the load event instead, but to the same failure.

Activity

  1. frankiefu commented on Jan 24, 2014

    @frankiefu
    Member

    the event name needs to prefix with on-

    <polymer-localstorage name="my-name" value="{{myName}}" on-polymer-localstorage-load="{{getName}}"></polymer-localstorage>

    More info here:
    http://www.polymer-project.org/polymer.html#declarative-event-mapping

  2. balupton commented on Jan 24, 2014

    @balupton
    Author

    😳 whoops, working now! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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