ngHttpPool

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

Angular Core Dependency: >=1.0.7

Module License: MIT

Added by: Sam Deering

GitHub

Repository

sparrowjang/nghttppool

Stats

Stars: 3

Watchers: 3

Forks: 0

Author

SparrowJang
SparrowJang

Module Description

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.

Module stats last updated: 2015-06-04 11:08:54

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!