如何让JS函数重新运行队列大小的更改

时间:2015-03-18 01:19:26

标签: javascript node.js meteor

我有一个队列,我想在每次添加一个值时在该队列上运行一个函数。我正在使用meteor,这是在服务器端btw。

 var Queue = [];
var callInQueue;    //current api call in the queue. will be the url and a callback

(function QueueLoop () {
    if (Queue.length) {
        callInQueue = Queue.shift();
        Meteor._debug(callInQueue);
    }
    else { Meteor._debug("nothing in there"); }
} ());

然后我以流星方法将值推入队列

 Meteor.methods({
testMethod: function() { Queue.push("hello"); } });

0 个答案:

没有答案