To introduce an onBoot method in CBWIRE components that triggers during both the initial rendering and subsequent requests. This method will be useful for operations like security validation.
Details
Currently, CBWIRE components utilize the onMount() method, which is only executed during the component's initial rendering. The proposed onBoot method will extend this functionality to be executed on every request (initial and subsequent) of the component.
Example Use Case 1 - Security Validation
component extends="cbwire.models.Component" {
function onBoot() {
if ( !isLoggedIn() ) {
return false;
}
return true;
}
}
In this example, onBoot() performs a security check to see if the user is logged in. If the user is not logged in (isLoggedIn() returns false), the component will not render.
Example Use Case 2 - Data Loading
component extends="cbwire.models.Component" {
function onBoot() {
loadData();
return true;
}
private function loadData() {
// Logic for data loading
}
}
Here, onBoot() is used for loading data every time the component is requested. This ensures that the component always has the latest data available, whether the initial load or a subsequent request.
Expected Functionality
Implement an onBoot method in CBWIRE components.
onBoot should be executed for both initial and subsequent renderings of the component.
If onBoot returns false, the component should not render. This behavior applies to both initial and subsequent requests.
Ensure that onBoot can accommodate various use cases like security checks, data loading, etc.
Update CBWIRE documentation to include details about the onBoot method, its implementation, and potential use cases.
Objective
To introduce an onBoot method in CBWIRE components that triggers during both the initial rendering and subsequent requests. This method will be useful for operations like security validation.
Details
Currently, CBWIRE components utilize the onMount() method, which is only executed during the component's initial rendering. The proposed onBoot method will extend this functionality to be executed on every request (initial and subsequent) of the component.
Example Use Case 1 - Security Validation
In this example, onBoot() performs a security check to see if the user is logged in. If the user is not logged in (isLoggedIn() returns false), the component will not render.
Example Use Case 2 - Data Loading
Here, onBoot() is used for loading data every time the component is requested. This ensures that the component always has the latest data available, whether the initial load or a subsequent request.
Expected Functionality