i am using a method (searchTransportation
) for an event callback.
exports.searchTransportation = function (items, num, UrlS) {
//...
}
exports.doHotelInsertion = function(items, num, typetransport, UrlS, callback) {
// (omitted code)
event.on("STARTWITHAIRSEARCH" + num, searchTransportation ); //!!! causes error
};
I tried smth like
event.on("STARTWITHAIRSEARCH" + num, this.searchTransportation(items, num,
UrlS).bind(this));
But this is breaking code and ends up with Object function () { } has no method 'searchTransportation'
I understand that the event callback is at the global scope but is there a way to call an existing method?
-- EDIT
this is a bit like this SO question : Class methods as event handlers in javascript but with a nodejs twist. What s the most elegant way of doing this?