2016-05-24 03:37:06 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-26 17:02:43 +08:00
|
|
|
function MapConfigAdapter() {
|
|
|
|
this.adapters = Array.apply(null, arguments);
|
2016-05-24 03:37:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = MapConfigAdapter;
|
|
|
|
|
|
|
|
MapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) {
|
|
|
|
var self = this;
|
|
|
|
var i = 0;
|
|
|
|
var tasksLeft = this.adapters.length;
|
|
|
|
|
|
|
|
function next(err, _requestMapConfig) {
|
|
|
|
if (err) {
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
if (tasksLeft-- === 0) {
|
|
|
|
return callback(null, _requestMapConfig);
|
|
|
|
}
|
|
|
|
var nextAdapter = self.adapters[i++];
|
|
|
|
nextAdapter.getMapConfig(user, _requestMapConfig, params, context, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
next(null, requestMapConfig);
|
|
|
|
};
|