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:
parent
2c4d5cb0bb
commit
0d420d7633
2 changed files with 86 additions and 0 deletions
35
js/msp/MSPchainer.js
Normal file
35
js/msp/MSPchainer.js
Normal 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue