javascriptevent-handlingpolymerdom-eventspolymer-1.0

Polymer element doesn't trigger the "on-<property>-changed" event when property changes


I am using the google-sigin element from the Polymer catalog. I want to listen to changes for the signedIn attribute outside the polymer element. The property is set to notify: true and in the Polymer documentation related to change notifications, it says that:

When using a Polymer element with other elements or frameworks, you can manually attach an on-property-changed listener to an element to be notified of property changes, and take the necessary actions based on the new value.

I have tried listening to on-signIn-changed, on-sign-in-changed, on-property-changed, signIn-changed and sign-in-changed, but none of these events are being triggered.

The code that listens to the event looks like:

document.addEventListener("DOMContentLoaded", function() {
    document.querySelector('google-signin').addEventListener('on-signIn-changed', function() {
        // never gets called
    });
});

I know that I could be listening to the google-signin-success event (which works and I can see that signedIn has been changed to true), but I want to understand why the event isn't being triggered/what I am doing wrong.


Solution

  • I noticed that property is called signedIn not signIn. Have you tried addEventListener('signed-in-changed'?