Skip to content

Potential race condition in lavaca/mvc/View #83

@zship

Description

@zship

An issue in View.prototype.render manifested itself in a recent project: when View.prototype.redraw is called at the same time as View.prototype.render, and the stars align just right, View.prototype.el can end up unset at the time self.el.addClass(self.className); is called. Here's the relevant code in lavaca/mvc/View:

    template
      .render(model)
      .success(promise.resolver())
      .error(promise.rejector())
      .then(function(html) {
        if (self.className){
          self.el.addClass(self.className);
        }
      });

The specific situation reads like this:

if (childView instanceof app.ui.views.**redacted view name**) {
  childView.render();
  childView.model.trigger('reset');
}

Where childView calls redraw on its model's "reset" event. Changing that to:

if (childView instanceof app.ui.views.**redacted view name**) {
  childView.render().then(function() {
    childView.model.trigger('reset');
  });
}

Appears to have fixed the issue. Observed only on Android compiled so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions