Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

ex-machine/ng-debottle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ng-debottle

Angular debounce/throttle portmanteau, now with $timeout flavour.

Wraps debottle package to provide generic JS debounce and throttle as Angular services.

Install

NPM

npm install --save ng-debottle

Bower

bower install --save ng-debottle

Usage

angular.module('app', ['ngDebottle'])
.run(function ($rootScope, $throttle, $debounce) {
	function fn() { ... }
	var throttledFn = $throttle(fn, 100);
	var debouncedFn = $debounce(fn, 100);

	// based on $timeout, synced to digest cycles 
	$rootScope.$on('...', throttledFn);
	$rootScope.$on('...', debouncedFn );
	// instead of
	$rootScope.$on('...', fn);
})
.run(function ($rootElement, throttle, debounce) {
	function fn() { ... }
	var throttledFn = throttle(fn, 20);
	var debouncedFn = debounce(fn, 20);

	// based on setTimeout, not synced to digest cycles
	$rootElement.on('...', throttledFn);
	$rootElement.on('...', debouncedFn);
	// instead of
	$rootElement.on('...', fn);
});

About

Angular debounce/throttle portmanteau, now with $timeout flavour

Resources

License

Stars

Watchers

Forks

Packages

No packages published