Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Make _.delay(), _.throttle(), and _.debounce() karma friendly #21

Open
mvindahl opened this issue Feb 24, 2015 · 3 comments
Open

Make _.delay(), _.throttle(), and _.debounce() karma friendly #21

mvindahl opened this issue Feb 24, 2015 · 3 comments

Comments

@mvindahl
Copy link

The three functions share the common trait that they use the native setTimeout function.

In angular, it's best practise to use $timeout instead. It offers the same signature, and on top of that it makes it possible to "short circuit time" from karma tests by calling $timeout.flush().

As far as implementation goes, I'm thinking of something along the lines of making the underscoreModule depend upon $timeout and including the three functions from underscore.js as shivs, replacing all instances of 'setTimeout' with '$timeout'.

If you approve of the idea, I could try to make it work and submit a pull request.

@floydwch
Copy link
Owner

@mvindahl Good insight! It's nice to see your PR :)

@jamiemcconnell
Copy link

+1 :)

@AndrewEastwood
Copy link

+1

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

4 participants