Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

perf($interpolate/$compile): port optimization from dart #6598

Closed

Conversation

rodyhaddad
Copy link
Contributor

Motivated by #4556 (comment)

More info about the optimization can be found in that PR.

Brief description:
This PR makes that given text like:
{{a}} text {{b}}
Instead of computing the whole string on each digest for dirty-checking,
We watch each expression individually, and only concatenate stuff when something changes.

To accomplish this, we use $scope.$watchSet. It has been implemented in AngularDart, but has been removed recently in favor of the change_detection lib

Edit: Travis tests are failing because npm failed? I'll try to have travis run again tomorrow

It any one expression changes then the listener function fires
Port of dart-archive/angular.dart@a3c31ce
@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#6598)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

if (fns.parts) {
fns = fns.parts;
if (fns.expressions) {
fns = fns.expressions;
Copy link
Contributor

Choose a reason for hiding this comment

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

@juliemr would this change also affect protractor? how do you introspect interpolations in protractor?

Copy link
Member

Choose a reason for hiding this comment

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

This should not require a change in Protractor. Protractor currently uses the element's data function and gets data('$binding').exp, which has not changed in this PR from what I see.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

@btford btford added this to the Backlog milestone Mar 17, 2014
@valtron
Copy link

valtron commented Mar 22, 2014

As per #6776, I'd like to weigh in and suggest the $watchSet functionality should also be available in $watch.

@IgorMinar
Copy link
Contributor

@valtron we'd like to avoid overloading the $watch method but we are definitely interested in providing this functionality via another method on the scope object.

BREAKING CHANGE: the function returned by $interpolate
no longer has a `.parts` array set on it.
It has been replaced by two arrays:
* `.expressions`, an array of the expressions in the
  interpolated text. The expressions are parsed with
  $parse, with an extra layer converting them to strings
  when computed
* `.separators`, an array of strings representing the
  separations between interpolations in the text.
  This array is **always** 1 item longer than the
  `.expressions` array for easy merging with it
@IgorMinar IgorMinar self-assigned this Apr 18, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-beta.6, Backlog Apr 18, 2014
@IgorMinar
Copy link
Contributor

landed as #7158

@IgorMinar IgorMinar closed this Apr 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants