What's New With 2.2
01/09/2022
New Features
Hydration Lifecycle Hooks
CBWIRE 2.2 introduces new hydration lifecycle methods that run when components are restored from their serialized state.
// wires/UserForm.cfc
component extends="cbwire.models.Component" {
data = {
"user" = {},
"originalEmail" = ""
};
function onMount(params = {}) {
data.user = getUser(params.userId);
data.originalEmail = data.user.email;
}
function onHydrate() {
// Called every time component is hydrated from state
logActivity("Form hydrated for user: " & data.user.name);
}
function onHydrateEmail(value, oldValue) {
// Called when 'email' property is hydrated
if (value != data.originalEmail) {
data.emailChanged = true;
}
}
}Auto-Trim Data Properties
All string data properties are now automatically trimmed of whitespace, ensuring cleaner data handling.
JavaScript Component Access
Components can now be accessed directly from JavaScript using the global cbwire.find() method.
Turbo SPA Support
New enableTurbo setting provides single-page application functionality for faster navigation.
When enabled, page navigation becomes faster with JavaScript-powered transitions instead of full page reloads.
Enhanced Reset Functionality
The reset() method can now reset all data properties when called without parameters.
Enhancements
Lifecycle Method Standardization
Updated lifecycle method naming for consistency - mount() is now onMount().
Improved Performance
Faster hydration process with optimized component restoration
Better memory management for long-running applications
Streamlined event handling and data binding
Bug Fixes
Event System Improvements
Fixed immediate listener firing: Event listeners no longer fire immediately when emitting from the same component
Proper event ordering: Ensured
onHydrate()runs before component actionsComputed property timing: Fixed computed properties not rendering correctly before actions execute
Documentation and Structure
Fixed DocBox integration: Resolved documentation generation issues caused by file structure changes
Better error handling: Improved error messages and debugging information
Component Lifecycle
Hydration timing: Ensured proper order of hydration lifecycle methods
State restoration: Fixed issues with component state not being properly restored in certain scenarios
Breaking Changes
Lifecycle Method Names
Update component lifecycle methods from mount() to onMount():
This change provides better consistency with other lifecycle methods and clearer naming conventions.
Was this helpful?