whats the best way to handle API interactions ? Le...
# compose
u
whats the best way to handle API interactions ? Lets say a set of screens need access to some report data from the API, where and when should the API call be made and how should the data be stored and accessible for all those screens ?
p
Encapsulate them in a navgraph and have a ViewModel with the UseCases scoped to this graph.
u
thanks, do you know of any example github repos or code I could look at to get a better idea ?
p
Honestly no, I do it all the time but in companies closed source. Now, there is a lot of guidance on how to do this. Even the official documentation.
Or look into stack overflow, I have seen this answered before. As simple as binding the SharedViewModel to the graph, and access it from the children NavBackstackEntries.
z
This is a general architecture question - nothing compose-specific here, compose is probably just your view layer.
👍 1