In the document example we can see :
var Queue = require('firebase-queue'),
Firebase = require('firebase');
var ref = new Firebase('https://<your-firebase>.firebaseio.com');
var queueRef = ref.child('queue');
var messagesRef = ref.child('messages');
var options = {
'specId': 'new_user'
};
new Queue(queueRef, options, function(data, progress, resolve, reject) {
// sanitize input message
console.log(data.message);
// pass sanitized message and username along to be fanned out
resolve(data);
});
How save a new task with the specId new_user
or other custom specId
var task = {'userId': "0338ba4d-191f-4044-9af0-4c76f47aeef9"};
ref.child("queue").child("tasks").push(task);
This push does not trigger the queue.
If I remove the options
from the Queue, it does work (of course)
tl;dr the start_state
for the spec should match the _state
of the task.
You need push the definition of each spec to the Firebase queue. For e.g.
ref.child('queue/specs').set({
new_user: {
start_state: 'add_new_user',
in_progress_state: 'add_new_user_in_progress'
}
});
Here new_user
is the specId that you have specified for the queue. Now when you push a task, you need to set the _state
to the start_state
for the spec. For e.g.
var task = {'userId': "0338ba4d-191f-4044-9af0-4c76f47aeef9", '_state': 'add_new_user'};
ref.child("queue").child("tasks").push(task);
Now this task should be picked up the queue that is created to handled tasks with specId
new_user
Read this and this in the official firebase queue documentation.