Reputation: 29
I have a master-detail app for android using kotlin and jetpack compose components. The flow in the app should be:
The problem is that I don t know how to call only at the first render the function from the view model. Right now , there is an infinite loop inside which the find function is called because I store the item provided by the view model inside an observableState. Every time that changes, the component is rerendered and the find function is called again. How can I call it only once?
Upvotes: 1
Views: 1394
Reputation: 160
You can get the id from savedStateHandle inside the screen viewModel and call the fetch from the init
block of the viewModel. This will be called once on page first composition.
Upvotes: 0