Hi everyone, I have a navigation drawer with a tra...
# compose
y
Hi everyone, I have a navigation drawer with a transaction report so whenever I press the "report" button in the nav drawer I want to fetch trasnaction using retrofit. I have a mutableList in my viewmodel and I update it with the data I get from the server. The problem is that in my screen I call getTransactions() and everytime the screen is composed this function is called over and over again. I understand the basic of compose and I know to handle states with remember, mutableStateOf etc., but I think I am missing something with lists. The exmaple I found are only shwoing how to fetch a one time list for example, a list of trivia questions and how to use it in the screen but not a test case where everytime you enter the screen you have to refresh the list and see if there are any new tranactions. Any ideas?
Alternatively if you don’t mind adding a side effect to your ViewModel then you can fetch reports inside the init block
y
I think init block is not an option because it runs only one time.