angular-queue

Processing/messaging queue for AngularJS

Module License: MIT

Added by: Sam Deering

GitHub

Repository

jseppi/angular-queue

Stats

Stars: 43

Watchers: 43

Forks: 16

Author

James Seppi
James Seppi

Module Description

angular-queue

Processing/messaging queue for AngularJS.

Based on http://benalman.com/code/projects/jquery-message-queuing/docs/files/jquery-ba-jqmq-js.html

Usage

Include angular-queue.js after your main AngularJS script.

Specify ngQueue as a dependency for your Angular application:

var app = angular.module('myApp', ['ngQueue']);

In your controller, services, etc, inject $queue, and create an instance to use:

app.controller("MyCtrl", ['$queue',
    function($queue){
        var myCallback = function(item) {
                console.log(item);
            },
            options = {
                delay: 2000, //delay 2 seconds between processing items
                paused: true, //start out paused
                complete: function() { console.log('complete!'); }
            };
        
        // create an instance of a queue
        // note that the first argument - a callback to be used on each item - is required
        var myQueue = $queue.queue(myCallback, options);
            
        myQueue.add('item 1'); //add one item
        myQueue.addEach(['item 2', 'item 3']); //add multiple items
        
        myQueue.start(); //must call start() if queue starts paused
    }]
);

License

MIT

Module stats last updated: 2017-09-08 15:00:03

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!