angular-underscore icon indicating copy to clipboard operation
angular-underscore copied to clipboard

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

Open mvindahl opened this issue 10 years ago • 3 comments

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.

mvindahl avatar Feb 24 '15 10:02 mvindahl

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

floydwch avatar Feb 25 '15 15:02 floydwch

+1 :)

jamiemcconnell avatar May 14 '15 07:05 jamiemcconnell

+1

AndrewEastwood avatar Jun 28 '16 19:06 AndrewEastwood