I have a function callWithMagic
which takes a callback function as a parameter and calls it with one argument.
const callWithMagic = callback =&
You can bind argument object to callback function:
var varObject = {var1: "findButton", var2: true};
function cbFunc() {
console.log(this.var1+ ":" + this.var2);
}
//Example callback
datatable.ajax.reload(cbFunc.bind(varObject));
You could use an anonymus function
something like
session.sub('Hello', function(){marketEvents(your args);});
You can create a function which calls the marketEvent
function. No need to complicate things
session.sub('Hello', function(args, kwargs) {
marketEvent(args, kwargs, 'my custom data');
});
otherwise you can do this:
var mrktEvent = function(customArgs) {
return function(args, kwargs) {
marketEvent(args, kwargs, customArgs)
};
}
session.sub('Hello', mrktEvent("customEvent"));
Just create a wrapper callback:
callWithMagic(function(magic) {
return processMagic(magic, 42);
});
Or using ECMAScript 6 arrow functions:
callWithMagic(magic => processMagic(magic, 42));