uiLogic
Exposes public functions defined in the form's UI Logic component as callable methods within the form's or steps' UI Logic event handler scripts.
To define a public function in the UI Logic component, assign it to this:
// In the UI Logic component
this.uiLogicFunction = function(){
console.log('calling a UI Logic function');
};
You can then use the uiLogic object in the form's (Before Generate, After Generate) and steps' (After Generate, Before Save, After Save) UI Logic event handler scripts to call the function as a method:
// In afterGenerate or other event handler scripts
uiLogic.uiLogicFunction()
For more information about client-side app logic components, see the code execution sequence documentation.
For a generic presentation of the design principles behind the organization of the View layer, see the FintechOS Architecture Overview.
Using Promises and Presenter Functions in UI Logic Functions
UI Logic functions can return promises, allowing UI Logic event handlers to perform asynchronous operations. Also, you can call presenter functions inside UI Logic function definitions. E.g.:
// In the Presenter component
this.presenterFunction = function() {
console.log('calling a presenter function');
return ebs.getByIdAsync('myEntityName', 'myRecordId');
};
// In the Ui Logic component
// Call the asynchronous Presenter function
this.uiLogicFunction = function(){
console.log('a UI Logic function that calls a Presenter function');
return presenter.presenterFunction();
};
In the event handler scripts, you can then call the UI Logic function and handle the result using the .then() and .catch() Promise instance methods as needed:
// In afterGenerate or other event handler scripts
return uiLogic.uiLogicFunction().then(function(x){
console.log(x);
console.log('end calling UI Logic from after generate');
}).catch(function(error) {
console.error('Error during UI Logic function call:', error);
});