Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Use $timeout rather than setTimeout #118

Closed
bbodenmiller opened this issue Mar 9, 2015 · 1 comment
Closed

Use $timeout rather than setTimeout #118

bbodenmiller opened this issue Mar 9, 2015 · 1 comment

Comments

@bbodenmiller
Copy link
Contributor

Per John Papa's Angular style guide it is better to use $timeout rather than setTimeout: https://github.com/johnpapa/angular-styleguide#timeout-and-interval

@urish
Copy link
Owner

urish commented Mar 9, 2015

In most of the cases, that is correct. However, there is a performance penalty when one uses $timeout, and it can also cause problems with you protractor end-to-end testing scenarios. See #5 and #66 for discussion.

One proposed solution was to use $interval and passing false in invokeApply. This should both skip the digest cycle and play nicely with protractor. However, the invokeApply parameter seems to be broken in AngularJS 1.2. Also, using $interval will probably result in a more complicated code.

Therefore, using setTimeout() is still the best solution for angular-moment.

@urish urish closed this as completed Mar 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants