You have already set connectOnStartup:true
in initOption.js
, this means that the app will try to connect to the Worklight Server on startup - basically it calls to connect
, so why do you call WL.Client.connect
in wlCommonInit()
as well?
As for the onSuccess and onFailure, I think that in this what you may want is the following:
See the options for WL.Client.init.
There is an initOption that you can uncomment in initOptions.js
:
- onConnectionFailure
A failure-handling function invoked when connection to the Worklight Server, performed on initialization by default, or if the connectOnStartup flag is true, fails.
The "success" by default is wlCommonInit()
, but you want something else then in initOptions.js
you can also add onSuccess: something
.
BTW, where did you see what you've done as a "best practice" by Worklight?