Is it possible to 'chain' functions? Say, I have a serverclickhandler and then would like to invoke another function after it right away. How do I go about it?
Thanks.
Is it possible to 'chain' functions? Say, I have a serverclickhandler and then would like to invoke another function after it right away. How do I go about it?
Thanks.
To have a second handler executed after the first one you just need to call it directly from your first handler, e.g.
var app = null;
function firstHandler(e) {
if( app == null )
app = UiApp.getActiveApplication();
//do your thing
//now, instead "return app;" you return the second handler
return secondHandler(e);
}
function secondHandler(e) {
if( app == null )
app = UiApp.getActiveApplication();
//do your job
return app;
}
I placed the app
var on a global scope so you can get it only when necessary (sharing it between the functions without explicit passing it), saving a possibly costly and unknown behavior (to me at least) of a second getActiveApplication()
call.
Not sure I understood exactly your question but serverhandlers to which you refer are precisely made for that... (see doc) Note that you can assign multiple handlers to UI elements to trigger different functions and eventually chain them.