dispatching a custom event from client (js) in v4

Hello!
I used following code in v3 and it worked fine

Backendless.enablePromises();
Backendless.Events.dispatch("eventName").then().....

but in v4 it does not work and i’m getting error

TypeError: Right-hand side of 'instanceof' is not callable
 at Events._dispatch (backendless@4.0.7-beta:4722)

Hello!

There is no more enablePromises method in v4: all methods are return promise by default.
Refer to this documentation for v4: https://backendless.com/docs/bl-js/doc.html#custom-events

Regards,
Stanislaw

I’m having same problem. Allow me to copy-paste my description from slack chat, (seems it got no attention) :

I wasn’t been able to call it successfully.
When I tried with async (copy-pasted from doc in 3.0)
var eventArg = {};
var successHandler = function( obj ) {console.log(‘ok’, obj);};
var errorHandler = function( obj ) {console.log(‘err’, obj);};
Backendless.Events.dispatch( “myCustomEvent”, eventArgs, new Backendless.Async( successHandler, errorHandler ) );
it gave me error Uncaught TypeError: Backendless.Async is not a function
and when I tried with promise it didn’t worked either
Backendless.Events.dispatch( “myCustomEvent”, {})
.then(function( obj ) {console.log(‘ok’, obj);})
.catch(function( obj ) {console.log(‘err’, obj);})
gave me error Right-hand side of ‘instanceof’ is not callable

I have a strong suspicion that you have a bug in SDK regarding dispatching custom event, (checking for async argument)
I managed to successfully call using workaround
Backendless.Events.dispatch( “myCustomEvent”, eventArgs, Date ).then(function( obj ) {console.log(‘ok’, obj);}).catch(function( obj ) {console.log(‘err’, obj);})
see “Date” as last argument

Hi Yuriy,

this issue will be fixed in ~1-2h, and we will release a new version of JS SDK with that fix.
I will notify you here and in Slack when it’s ready. Thanks for your patience.

Regards,
Stanislaw

SDK with the fix has been updated, please update version in your dependencies to 4.0.8.

thanks