ViewModel
val wordPressPostList: List<WordPressPostDataDomain>
field = mutableListOf<WordPressPostDataDomain>()
// States goes here...
is RequestStatus.Success -> {
if (it.data.postList.isNotEmpty()) {
wordPressPostList.addAll(it.data.postList)
}
_wordPressPostsState.send(WordPressPostsState.FetchSuccess(wordPressPostList.toList()))
}
Fragment
newsAdapter.submitList(state.postList)
ListAdapter won’t work without calling .toList()
either state.postList
or when passing it to state WordPressPostsState.FetchSuccess
in ViewModel