Skip to content

Helps you interact with your firebase data in a more uniform way.

Notifications You must be signed in to change notification settings

troylelandshields/firebase-alphaqueuejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firebase-alphaqueuejs

Helps you interact with your firebase data in a more uniform way.

Install it:

npm install --save firebase-alphaqueuejs

or

bower install --save firebase-alphaqueuejs

Include it:

Node

var AlphaQueue = require('firebase-alphaqueuejs')

Browser

<script src="path/to/firebase-alphaqueue.js"></script>

Use it:

//Get a ref to the task child of your firebsae database
var firebaseTaskRef = rootFirebaseRef.child("queue").child("tasks")

//instantiate a new Alpha Queue service with the names of your tasks
//AlphaQueue assumes your specs define states in the following way:
//      starting state = taskName_start
//      error state = taskName_error
//      finished state = taskName_finished
var animalSvc := new AlphaQueue(firebaseTaskRef, [
    "createAnimal",
    "feedAnimal",
    "petAnimal"
]);

//Push data to the queue and get a promise back
var dogPromise = animalSvc.createAnimal({
    name: "dog",
    slogan: "man's best friend"
});

//The promise is resolved when the task is finished (or rejected on error)
var dogPromise.then(function(dog){

    var catPromise = animalSvc.createAnimal({
        name: "cat",
        slogan: "alpha queue up",
        hates: {
            dog.id: true
        }
    });

    catPromise.then(function(cat){
        animalSvc.feedAnimal(cat.id)
    });
});

About

Helps you interact with your firebase data in a more uniform way.

Resources

Stars

Watchers

Forks

Packages