Skip to content

An angularjs module that is able to limit requests at the same time.

License

Notifications You must be signed in to change notification settings

SparrowJang/ngHttpPool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngHttpPool

An Angularjs module that is able to limit requests at the same time.

Dependency

  • angularjs

Install

bower install ngHttpPool

Usage

Require ngHttpPool and inject the services

angular.module( "app", [
	"ngHttpPool"
]).controller('ctrl',function( httpPool ){

});

Create a instance

Limit max request amounts by contructor:

var pool = httpPool.create( 2 );

Send a request

Set a http config by map function:

pool.map({method:"get",url:"/"});

Optionally, specify success and fail callbacks:

pool.map({method:"get",url:"/"}, success, error);

Send some requests and get all of the callbacks.

Create a defer.

pool.listen()

Add and run requests to pool.

for( var index = 0; index<10 ; index++ ){

  pool.map({method:"get",url:"/",params:{id:index}});
}

Get a promise of callbacks.

var promise = pool.Promise();

promise.then(function(){
  console.log( "all of the callbacks." );
});

Demo

Clone this project.

git clone http://github.com/SparrowJang/ngHttpPool.git

cd ngHttpPool

Install the express framework and grunt modules.

npm install

run a server:

grunt server

Finally,open your brower,enter http://localhost:3000/demo/index.html.

About

An angularjs module that is able to limit requests at the same time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published