Page History
...
Hooking up into component lifecycle
Two new function's support Support has been added in Servoy 2022.06 for two new handler functions. These can be defined for hooking up into the destroy / create component's lifecycle on the client side :
showComponent() : which is called every time the component is going from hide to show
hideComponent(): which is called when component is going from show to hide.
Any wanted processing for these situations may be added by adding these two functions in the internalApi section of the spec and also defining them on the server side scripting of the component.
This support is available from Servoy Developer v 2022.06.0destroy / create lifecycle.
These two methods will be called directly in server-side scripting when the component is shown/hidden on client. They are useful because - for example - some components want to do cleanup actions when they get hidden - but it is too late to call a server-side api when the component detects that it is destroyed on client, because server will normally block that call - the form is already known to be hidden (sometimes, in rare cases, at that point it may even be destroyed).
Any code the component wants to execute server-side for show/hide can be added to these two functions by:
- defining them in the server side scripting file of the component
onShow: which will be called every time the component gets shown
Code Block language js $scope.onShow = function() { // code to execute when the component is shown/created in the client. }
onHide: which will be called every time the component gets hidden
Code Block language js $scope.onHide = function() { // code to execute when the component is hidden/destroyed in the client. }
defining them in the internalApi section of the component's .spec file:
Code Block language js "internalApi": { "onHide": {}, "onShow": {} }