Out-of-Band Updates
Out-of-Band (OOB) updates allow you to update multiple DOM elements from a single WebSocket response, enabling rich, multi-area updates that keep your UI in sync across different sections of your application.What Are OOB Updates?
OOB updates let you update elements outside of the main target element specified in the client request. This is particularly useful for:- Updating navigation counters
- Showing notifications
- Refreshing status indicators
- Updating multiple related sections
- Maintaining consistency across the UI
Basic OOB Updates
Single OOB Update
Multiple OOB Updates
OOB Update Structure
WSXOOBUpdate Interface
Example with Different Swaps
Real-World Examples
E-commerce Cart Update
Dashboard Updates
Real-time Chat with Activity
Advanced OOB Patterns
Conditional OOB Updates
Dynamic OOB Generation
OOB with Broadcasting
OOB Update Helpers
Utility Functions
OOB Builder Pattern
Performance Considerations
Efficient OOB Updates
- Minimize the number of OOB updates per response
- Use specific selectors to avoid unnecessary DOM queries
- Batch related updates when possible
- Consider the impact on client-side performance
OOB Update Strategies
Best Practices
- Use Sparingly: Don’t overuse OOB updates - they can make debugging difficult
- Specific Selectors: Use specific CSS selectors to avoid conflicts
- Consistent Patterns: Establish patterns for common OOB updates
- Document Dependencies: Document which elements depend on which actions
- Error Handling: Handle cases where OOB targets don’t exist
- Performance: Monitor performance impact of frequent OOB updates
Next Steps
- Learn about Broadcasting for multi-client updates
- Explore Client Configuration for OOB settings
- Understand Server Broadcasting for real-time features