DefaultTrafficLineViewModel

class DefaultTrafficLineViewModel(navigationManager: NavigationManager) : TrafficLineViewModel

Default implementation of TrafficLineViewModel that manages traffic line visualization state and route objects.

This ViewModel:

  • Tracks user's position along the route

  • Manages traffic speed color data for the route visualization

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

  • Provides reactive updates as the user progresses along the route

Important: Call onCleared when this ViewModel is no longer needed to properly release resources and close all connections to prevent memory leaks.

Parameters

navigationManager

Provides navigation state and route information updates.

Constructors

Link copied to clipboard
constructor(navigationManager: NavigationManager)

Properties

Link copied to clipboard
open override 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
open override 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
open override 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
open override fun onCleared()

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