I'm migrating an app from views to compose and am trying to trigger a schedule update every five minutes in which if there is a change in the data compose should recompose. Still using RxJava in my vm, but I see getDataList() get called every 5 minutes, but I'm unsure how to update the list when dealing with state.
Here's my code so far: In compose
val dataList by viewModel.data.observeAsState() LaunchedEffect(Unit) { while(true) { viewModel.getDataList() delay(5 * 60 * 1000) } } In viewmodel
private val _data = MutableLiveData<List<Item>>() val data: LiveData<List<Item>> = _data fun getDataList() { compositeDisposable.add(repository .getData() .subscribe( { data -> _data.postValue(data) }, { it.printStackTrace() })) }