TrafficLineViewModel

ViewModel interface for managing traffic line visualization state and route objects.

Responsible for:

  • Tracking user's position along the route

  • Managing traffic speed color data for the route visualization

  • Handling traffic objects (accidents, road works, intermediate points) visibility

  • Providing reactive updates as the user progresses along the route

Thread Safety

This ViewModel is not thread-safe and must only be accessed from the Main thread.

  • All methods must be called from the Main (UI) thread

  • All StateFlow properties emit values on the Main thread

  • Concurrent access from multiple threads may lead to undefined behavior

Inheritors

Properties

Link copied to clipboard
abstract val position: StateFlow<Float>

Observable normalized route position indicating the user's progress. Value range 0..1, where 0 represents the start and 1 represents the end of the route. Updates as the user moves along the route.

Link copied to clipboard
abstract val trafficLineInfo: StateFlow<TrafficLineInfo?>

Observable traffic line information containing data needed to render the traffic visualization. Includes route length and traffic speed color entries. Null when no traffic data is available or the component is not properly initialized.

Link copied to clipboard
abstract val trafficObjects: StateFlow<List<TrafficLineObjectModel>>

Observable list of traffic objects to be displayed along the route. Includes accidents, road works, and intermediate route points. Objects are automatically filtered based on user position and include removal state for animations.

Functions

Link copied to clipboard
abstract fun onCleared()

Cleans up resources and closes all connections. Must be called when the ViewModel is no longer needed to prevent memory leaks.