Model attribute causing infinite loop

edited January 2014 in Enyo 2.4
Hey all, I ran into a problem with the new enyo.Model kind yesterday.

I've got a simple enyo.Model, with nothing more than a urlRoot, a readOnly flag, and as hash of defaults. For some reason I suddenly started running into an infinite loop when instantiating the model and passing it to my ModelController. After digging around, I finally found the problem:

One of the model's attributes is called "model".

As it turns out, this triggers an infinite loop on my ModelController, which triggers the "modelChanged" callback upon instantiating the model, which in turn calls the "sync" method, which syncs the attributes. For each attribute a callback is triggered. In the case of the "model" attribute, this would be "modelChanged", which triggers the "sync" method again and so on and so forth.

I don't know if this counts as a bug or if it's by design, but it would be nice to either find a solution allowing attributes called "model", or to update the documentation to list "model" as a reserved word that should not be used as a models' attribute name.

Comments

  • Thanks for posting this @ruben_vreeken. At this moment, 'model' is indeed a reserved word (when using enyo.ModelController) and the documentation needs to be updated to better reflect that. Very sorry for the troubles on that. I would very much like to see this change in a future release to be less inhibiting.
  • Thanx for the feedback. For now I'm able to work around it, but I agree it would be nice to eventually have a solution that's less inhibiting.
Sign In or Register to comment.