2

我有一个 Firebase 队列和两个规范,在同一个队列上,并且从客户端我正在推送队列,开始状态仅为 read_write_start,要么我的两个规范默认执行,要么执行错误的规范,即“ read_start" 规范被执行

客户端 :

var readWriteTokenData = {};
                        readWriteTokenData ["_start"] = "read_write_start";
$firebaseArray(QueueRef.child('tasks')).$add(readWriteTokenData);

服务器端 :

var queueRef = new Firebase('https://<INSTANCE>.firebaseio.com/queue');

    var specs: {
        "read_write_token": {
            "_start_state" : "read_write_start",
            "in_progress_state": "read_write_in_progress",
            "finished_state": "read_write_finished",
            "error_state": "read_write_error"
        },
        "read_token": {
            "_start_state" : "read_start",
            "in_progress_state": "read_in_progress",
            "finished_state": "read_finished",
            "error_state": "read_error"
        }
     }

    queueRef.child('specs').update(specs);

    var option1 = {
        'specId' : 'read_token',
        'numWorkers': 1
    };

    var option2 = {
        'specId' : 'read_write_token',
        'numWorkers': 1
    };

var ReadQueue = new Queue(queueRef,option1,function(data, progress, resolve, reject) {

    data.readToken = 'PQR';

    if(readToken){
        resolve(data);
    } else {
        reject(data);
    }
});

var ReadWriteQueue = new Queue(queueRef,option2,function(data, progress, resolve, reject) {

    data.readWriteToken = 'ABC';
    if(readWriteToken){
        resolve(data);
    } else {
        reject(data);
    }
});

我不确定我在这里缺少什么文档不清楚

我是否必须为每个规范实例化一个新的队列引用?规范仅用于链接作业吗?

我应该这样做吗

var queueRef1 = new Firebase('https://<INSTANCE>.firebaseio.com/read/queue');
var queueRef2 = new Firebase('https://<INSTANCE>.firebaseio.com/readwrite/queue');
4

0 回答 0