Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

refactor(multiCheckBox): Improve performance #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blowsie
Copy link

@blowsie blowsie commented Nov 3, 2015

  • Improve performance by moving $watch to the exact model

- Improve performance by moving $watch to the exact model
for (var index = 0; index < newOptionsValues.length; index++) {
$scope.multiCheckbox.checked[index] = modelValue.indexOf(newOptionsValues[index][valueProp]) !== -1;
}
$scope.$watch('to.options', function optionsWatcher(newOptionsValues) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this will do is essentially create a new watcher every time the model changes. Probably not something we want to do...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I can see this could be an issue, but maybe your missing that this code is already in the repo?

With the way it is pre my changes, this watcher is created every time any section of the form model changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awe dang, you're right! Hmmm... We should probably fix that... I'll create an issue.

@kentcdodds
Copy link
Member

Sorry, I appreciate what you're trying to do, but I don't think that this will work well. Have you noticed perf issues with this watcher?

@blowsie
Copy link
Author

blowsie commented Nov 4, 2015

Well, I just noticed on large forms that this is being called 100s or 1000s of times and sometimes the multiCheckBox is not even being touched.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants