cleanupBeforeDestroyComplete function
If your task defined a cleanupBeforeDestroy function, call the cleanupBeforeDestroyComplete function to inform z/OSMF core that your cleanup actions are complete and that your task is ready to be closed.
Invoking the function
To call the cleanupBeforeDestroyComplete function, use the syntax shown in Figure 1.
win.global.zosmfExternalTools.cleanupBeforeDestroyComplete(obj);
- obj
- Name of the parameter that was passed to the cleanupBeforeDestroy function.
The cleanupBeforeDestroyComplete function must be called after your cleanupBeforeDestroy function completes. Otherwise, z/OSMF might close the task before the cleanup actions are complete.
For example, if your cleanupBeforeDestroy function is performing an XMLHttpRequest (XHR) call, the cleanupBeforeDestroyComplete function must be called at the end of the XHR call and not immediately after the XHR call is issued.
Example
win.global.zosmfExternalTools.cleanupBeforeDestroy = function(obj) {
//A synchronous cleanup method that cleans up objects on the client
//to free up memory.
myApi.cleanupMethod();
//Inform z/OSMF core that the cleanup actions are complete
//and that the task is ready to be closed.
win.global.zosmfExternalTools.cleanupBeforeDestroyComplete(obj);
};
If myApi.cleanupMethod() is an asynchronous method, call the cleanupBeforeDestroyComplete function after the asynchronous action completes. Otherwise, the asynchronous method might not have time to complete.