angular-ui / ui-ace

This directive allows you to add ACE editor elements.
http://angular-ui.github.io/ui-ace
MIT License
578 stars 172 forks source link

Watch Handler Gets Called Twice #46

Closed ndibek closed 10 years ago

ndibek commented 10 years ago

Watch handler is called twice this causes onload to get called twice which can cause problems. According to https://docs.angularjs.org/api/ng/type/$rootScope.Scope#methods_$watch we can add a check to only handle changes.

Added check to watch of attrs.uiAce so that the handler only gets called when something actually changes

ciel commented 10 years ago

I can confirm that this fixed this same problem for me. Is there a reason this change is not part of the official file now?

ciel commented 10 years ago

@douglasduteil

Could we please get this merged with the official source? This fix is really good, I ran some tests and this literally cut the plugin's memory consumption by half. I have made the modification to my own file and it works wonderfully, I've noticed no side effects and only the two lines proposed have to change.

douglasduteil commented 10 years ago

Immediately sry for the wait. Thanks @ndibek @ciel

ciel commented 10 years ago

That is okay, I am just excited it got added. I am loving this project, so I actually just submitted my own pull request!