-
Notifications
You must be signed in to change notification settings - Fork 0
Design and Architecture
The NetworkApi
interface provides the structure for backend API calls (i.e. GET vs. POST and request bodies). The actual OkHttp/Retrofit client is provided by Dagger code generation, which is specified in NetworkModule
.
The RouteRepository
singleton is the origin of all network calls to the backend. To accomplish this, RouteRepository
interfaces with NetworkApi
. Once RouteRepository
retrieves data, it is emitted through Flows corresponding to the data retrieved. These Flows are accessible from the ViewModels which have a reference to the RouteRepository
singleton.
The HomeViewModel
exposes stopFlow
, the list of all stops, to its Views. The list of all stops is used primarily for searching. Searching uses a StateFlow searchQuery
of the current query in the search bar and combines it with stopFlow
to create a new Flow with a list of search-filtered stops. This new queryFlow
is exposed to its Views.
HomeViewModel
also exposes lastRouteFlow
, which holds the data from the last request to backend for possible routes.
TODO
HomeScreen
updates its UI through the Flows exposed from HomeViewModel
.
RouteScreen
updates its UI using lastRouteFlow
and calls the ViewModel function getRoute
to get new updated data from lastRouteFlow
.