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.8 array notification #1477

Merged
merged 17 commits into from
May 5, 2015
Merged

0.8 array notification #1477

merged 17 commits into from
May 5, 2015

Conversation

kevinpschaaf
Copy link
Member

Removes use of ArrayObserve.observe. Instead, users must use this.push(), etc. on elements to mutate arrays. Collection is also no longer observable; simply stands as a store of key->item and item->key mappings for arrays.

Renames getPathValue and setPathValue to get and set.

get and set can now take an array of path parts, to avoid needing to concat, e.g. set([items', 4, 'name'], 'bob);, and also does automatic array index-to-key mapping when notifying path (4 in example would be replaced with the key for items[4] when notifying).

Renames _data to __data__ to avoid collision with user data.

@arthurevans
Copy link

What's the motivation for this change? Is Array.observe too heavy-weight, or just not working right?

@kevinpschaaf
Copy link
Member Author

@arthurevans Prior to this change, we used Array.observe (on Chrome) but on all other browsers overrode array instances with patched push/pop/etc. methods to be able to observe when changes occurred (remember, we're avoiding the observe-js polyfill overhead for Polymer proper). The patching approach was not only intrusive, but led to a hard-to-explain API w.r.t. making changes to structured data (if you want to set set this.items[4] and have Polymer see it, you need to use this.set, but if you want to push onto this.items, you could just push onto the array). Now, all mutation of objects/arrays should be done through Polymer.Base API's:

  • get
  • set
  • push
  • pop
  • shift
  • unshift
  • splice

@sorvell
Copy link
Contributor

sorvell commented May 5, 2015

LGTM

sorvell pushed a commit that referenced this pull request May 5, 2015
@sorvell sorvell merged commit d6f91a4 into 0.8-preview May 5, 2015
@sorvell sorvell deleted the 0.8-array-notification branch May 5, 2015 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants