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

remove isInitial check on recompute #856

Merged
merged 4 commits into from
Sep 17, 2017
Merged

remove isInitial check on recompute #856

merged 4 commits into from
Sep 17, 2017

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Sep 17, 2017

Occurred to me that we can remove the isInitial check on computations by creating a changed object that includes all keys that computations depend on for the first run:

// instead of this...
App.prototype._recompute = function _recompute(changed, state, oldState, isInitial) {
  if (isInitial || changed.a || changed.b) {
    if (differs((state.c = template.computed.c(state.a, state.b)), oldState.c)) changed.c = true;
  }
}

// ...this:
App.prototype._recompute = function _recompute(changed, state) {
  if (changed.a || changed.b) {
    if (differs(state.c, (state.c = template.computed.c(state.a, state.b)))) changed.c = true;
  }
}

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

Successfully merging this pull request may close these issues.

None yet

1 participant