How UnPeek-LiveData works and when to use it
masterUnPeek-LiveData is a specialized data distribution tool designed for the Domain Layer to solve the "data backflow" (data re-injection) problem common with standard Jetpack LiveData.
Key Characteristics
- Multi-observer support: A single message can be consumed by multiple observers.
- Controlled backflow prevention: It prevents data re-injection only after all observers have consumed the message.
- Manual memory management: You can use the
clear()method to manually remove messages from memory. - Read/Write Separation: Supports a "Single Source of Truth" pattern using access control (e.g.,
ProtectedUnPeekLiveData).
Usage Constraints
- Low-frequency data distribution: It is optimized for scenarios like pushing data once per second.
- High-frequency requirements: If you need to dispatch events more frequently (e.g., 5+ times per second), use MVI-Dispatcher instead, as it uses a message queue to ensure no pushes are missed.