dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
180 stars 33 forks source link

Prototype a custom list class which uses a JsArray. #526

Closed jakemac53 closed 9 years ago

jakemac53 commented 9 years ago

Currently we keep both a dart list and a js array around, and have to keep them in sync. This only works if people go through the proper list modification apis, and is generally fragile as well as using double the memory.

If we want to unify the two, we will probably have to use a custom List class, which actually uses a JsArray to store all objects. This is because we can't override the index operator in js, so we can't create a custom array in js that reads from a dart list.

Other solutions welcome as well, please add them here :).

We will need to evaluate the performance impacts of this.

a14n commented 9 years ago

The upcoming changes in dart:js from @jacob314 could help here. (See https://codereview.chromium.org/1177953010/ and https://codereview.chromium.org/1213873004)

In addition to typed interop the Dartium CL lets you pass List objects back and forth between Dart and JS. A Dart List shows up as a JS Array and vice versa... so no more jsify calls are required for arrays!

Nevertheless I'm not sure the polymer package has a time frame compatible with those changes (only in Dartium for now).

jakemac53 commented 9 years ago

Yes, I am aware of those changes but I don't want to block polymer on them. We also have the same issue for dart Maps, although that is easy to fix by just creating a class instead of a map, as long as you don't need a dynamic structure.

jakemac53 commented 9 years ago

duplicate of https://github.com/dart-lang/polymer-dart/issues/586