Implementation
Key Features
Wire to Function
The@wire decorator binds the Apex method to a function that receives data and error:
Separate Properties
Managecontacts and error as separate reactive properties:
Data Processing
The function allows you to:- Transform data before storing it
- Perform calculations or filtering
- Manage multiple properties
- Add custom logic based on response
Error Handling
Explicitly handle errors and clear previous states:Advantages Over Property Binding
- Data Transformation: Process data before assigning to properties
- State Control: Explicitly manage when to clear or update state
- Custom Logic: Add business logic in the response handler
- Multiple Properties: Update multiple properties from single response
When to Use
Use this pattern when:- You need to transform or process data before display
- You want explicit control over state management
- You need to update multiple properties
- You want to add custom error handling logic
Comparison with Property Binding
| Feature | Property Binding | Function Binding |
|---|---|---|
| Code simplicity | Simple | Moderate |
| Data processing | None | Full control |
| State management | Automatic | Manual |
| Error handling | Built-in | Custom |
| Use case | Simple display | Complex logic |
