1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-19 14:25:13 +03:00

chainer for MSP requests

This commit is contained in:
U-PAWEL-X220\pawel 2017-01-06 19:59:19 +01:00
parent 2c4d5cb0bb
commit 0d420d7633
2 changed files with 86 additions and 0 deletions

35
js/msp/MSPchainer.js Normal file
View file

@ -0,0 +1,35 @@
/*global $*/
'use strict';
var MSPChainerClass = function () {
var self = {};
self.chain = [];
self.exitPoint = null;
self.chainIndex = 0;
self.setChain = function(chain) {
self.chain = chain;
};
self.setExitPoint = function (exitPoint) {
self.exitPoint = exitPoint;
};
self.returnCallback = function () {
self.chainIndex++;
if (self.chain[self.chainIndex]) {
self.chain[self.chainIndex](self.returnCallback);
} else {
self.exitPoint();
}
};
self.execute = function() {
self.chainIndex = 0;
self.chain[self.chainIndex](self.returnCallback);
};
return self;
};