Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.0.9-rc.1] Array changes event is not delivered #1523

Closed
ragingwind opened this issue May 13, 2015 · 3 comments
Closed

[0.0.9-rc.1] Array changes event is not delivered #1523

ragingwind opened this issue May 13, 2015 · 3 comments

Comments

@ragingwind
Copy link
Contributor

I've testing in 0.9.0-rc.1. I couldn't get events from a changed of array by Array mutation API. It seems that 'users-changed' event is not bind to the node. I confirmed that node.dispatchEvent is called but userAddedOrRemoved is never called until I binded users-changed event to the node in manually for testing. here is my test code and logs.

Polymer({
  is: 'x-custom',

  properties: {
    users: {
      type: Array,
      value: []
    }
  },

  observers: [
    'usersAddedOrRemoved(users.splices)'
  ],

  usersAddedOrRemoved: function(changeRecord) {
    console.log('usersAddedOrRemoved', changeRecord);
  },

  addUser: function(user) {
    this.push('users', user);
  },

  removeUser: function(user) {
    var index = this.users.indexOf(user);
    this.splice('users', index, 1);
  }
});

var xs = document.querySelector('x-custom');

// usersAddedOrRemoved is not fired
xs.addUser('John');
xs.removeUser('John');
xs.fire('users.splices');
xs.fire('users.changed');

// usersAddedOrRemoved is fired
xs.addEventListener('users-changed', xs.usersAddedOrRemoved);
xs.addUser('John');
xs.removeUser('John');
@ragingwind
Copy link
Contributor Author

Still exist in 0.9. The test code something went wrong?

@arthurevans
Copy link

Hi -- I'm not seeing this issue when I put your code in jsbin:

http://jsbin.com/jitoqe/1/edit?html,console,output

I am seeing an extra call to usersAddedorRemoved (perhaps that represents the empty state). But it seems to work...

@ragingwind
Copy link
Contributor Author

Sorry for bothering you. I works well with 0.9 after reinstalling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants