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

Interweave with Map should respect existing List type #14

Open
rjgotten opened this issue Sep 5, 2016 · 0 comments
Open

Interweave with Map should respect existing List type #14

rjgotten opened this issue Sep 5, 2016 · 0 comments

Comments

@rjgotten
Copy link

rjgotten commented Sep 5, 2016

Currently, List interweaves with Map via

Map.setup = function(){
  oldSetup.apply(this, arguments);
  if (!(this.prototype instanceof List)) {
    this.List = Map.List.extend({
      Map: this
    }, {});
  }
};

can-list.js; lines 936-943

This foregoes any custom, derived type of List that may already have been defined on a particular Map subclass. This would be easily fixed by updating the code in question to check for pre-existence of a List value beforehand:

Map.setup = function(){
  oldSetup.apply(this, arguments);
  if (!(this.prototype instanceof List)) {
    this.List = (this.List || Map.List).extend({
      Map: this
    }, {});
  }
};

Derived generic List classes are very useful when you want to add generic custom behavior to all instances of a particular Map class. E.g. I could (and infact do) have a derived ResizableList with a settable length property that allows growing/shrinking the list, transparantly adding/removing members of the list's Map type based on its default initialization.

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

1 participant