Problem with enyo.Model subkinds

edited October 2013 in Enyo 2.4
I'm trying to code the models hierarchy but the submodels don't inherit any attributes from their parent. Simple jsFiddle shows this behavior:

What should I do to get the partent's attributes in the submodels?


  • edited October 2013
    In the latest version, enyo.Model is a very simple kind that doesn't inherit from enyo.Object. This is done for speed, as model objects are often created in large numbers.

    Because of this, it doesn't have the "sublcass" mechanism for extending array/object kinds that kinds derived from enyo.Component have. It's just not designed for inheritance. I suggest you use another mechanism, like an external attributes object you can mixin to the child models, for this, as we don't want to have to pay the cost for supporting that mechanism in the base model kind.

    Oops... got schooled by Cole on this... he did intend for extension to work, so he's looking into a fix that will preserve the fast creation time but allow extending the properties on models.
  • Oops .. got schocked by Ben on this .. :)
    Ben - thanks for editing your post 2h later.
    Glad to see that inheritance should stay available for all kinds.
  • Well, inheritance worked, it was just the combination of the parent and child attributes properties that isn't right in the current code.
  • Hey guys there's a PR up ( I'm having @unwiredben look into. It has a lot of unrelated changes in it but it also includes the fixes for the model inheritance issue (which was gnarly to say the least). If you have the time feel free to test the branch out ('post-9-update'). Otherwise I hope we'll have this merged in a day or 2.
Sign In or Register to comment.