Hey guys,
I wanted to dispatch a custom event from one of my services. (Node JS throughout). I’ve found some documentation on the topic and followed the suggestions provided, however, if seems like nothing works and to make matters worse, there is no error fired when a service doesn’t exist, so it’s proving quite difficult to track down the issue. Would be really nice if someone could point me in the right direction.
Here’s an overview of my current situation
app
- handlers
-
- custom-events
-
-
- myCustomEvent.js
-
myCustomEvent.js
/**
* @param {Object} req The request object contains information about the request
* @param {Object} req.context The execution context contains an information about application, current user and event
* @param {Object} req.args
*
* @returns {Object|Promise.<Object>|void} The event caller will receive this value
*/
Backendless.ServerCode.customEvent('myCustomEvent', function(req) {
console.log("event arguments: " + req.args);
});
This is how I dispatch my custom event from my service. (I lifted this directly from the documentation)
var eventArg = { doData: "test" };
var successHandler = function() {
console.log("ok");
};
var errorHandler = function() {
console.log("not ok");
};
return Backendless.Events.dispatch("myCustomEvent", eventArg)
.then( successHandler )
.catch( errorHandler );
If I attach in debug, I can see that the flow doesn’t invoke my custom event, also my logs aren’t fired, I simply see ok printed in the console