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

Potential race condition in lavaca/mvc/View #83

Open
zship opened this issue May 20, 2013 · 0 comments
Open

Potential race condition in lavaca/mvc/View #83

zship opened this issue May 20, 2013 · 0 comments

Comments

@zship
Copy link
Contributor

zship commented May 20, 2013

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.

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