Understanding the binding system
Learn how Aurelia's binding system balances synchronous notifications with async computed updates and how to manage state safely.
Synchronous vs Asynchronous Updates
Observable Properties: Synchronous
import { observable } from 'aurelia';
class User {
@observable firstName = '';
@observable lastName = '';
}
const user = new User();
// This triggers immediate notifications
user.firstName = 'John'; // Subscribers notified immediately
user.lastName = 'Doe'; // Subscribers notified immediatelyComputed Properties: Asynchronous by Default
Understanding State Tearing
Example: Synchronous Computed Properties Can Still Tear
Managing State Updates with Batch
Fixing State Tearing with Batch
Comparing Sync vs Async Computed Properties
When to Use Sync vs Async Computed Properties
Use Async Computed Properties (Default) When:
Use Sync Computed Properties When:
Benefits of Using Batch
Best Practices
Next steps
Last updated
Was this helpful?