presenter
Exposes public functions defined in the Presenter component as callable methods within the UI Logic context.
To define a public function in the Presenter component, assign it to this:
Copy
// In the Presenter
this.presenterFunction = function(){
console.log('calling a presenter function');
};
You can then use the presenter object in the UI Logic event handler scripts (Before Generate, After Generate, Before Save, After Save) and the form's UI Logic component to call the function as a method:
Copy
//In the UI Logic
presenter.presenterFunction()
NOTE
For more information about client-side app logic components (both the Presenter and UI Logic), 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.
For more information about client-side app logic components (both the Presenter and UI Logic), 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 in Presenter Functions
Presenter functions can return promises, allowing UI Logic event handlers to perform asynchronous operations. E.g.:
Copy
// In the Presenter:
this.presenterFunction = function() {
console.log('calling a presenter function');
return ebs.getByIdAsync('myEntityName', 'myRecordId');
};
In the UI Logic, you can then call the presenter function and handle the result using the .then() and .catch() Promise instance methods as needed:
Copy
// In the UI Logic:
presenter.presenterFunction().then(function(result) {
console.log(result);
console.log('end calling presenter from after generate');
}).catch(function(error) {
console.error('Error during presenter function call:', error);
});