1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
var myFactory = function(){
var globalConnection = null;
var myFactory = this;
var init = function (options) {
if (options && options.rootPath) {
globalConnection = "1";
} else {
globalConnection = "2";
}
};
return function (havingLog, options) {
if (globalConnection === null) {
init(options);
}
myFactory.connection = globalConnection;
if (options && options.listeners) {
jQuery.each(options.listeners, function (event, fn) {
//code
});
}
if (options && options.methods) {
options.methods.forEach(function (method) {
//code
};
});
}
return myFactory;
};
};
var myHub = function(){
var....
return new myFactory()(logging, {
methods: ['method1', 'method12'],
listeners: {
'onLis1': function () {
//code
},
'onLis2' : function (exchangeDetails) {
//code
}
}
});
}
return myHub
} |
Partager