ViewModel
<code>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()))
}
</code>
<code>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()))
}
</code>
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
<code>newsAdapter.submitList(state.postList)
</code>
<code>newsAdapter.submitList(state.postList)
</code>
newsAdapter.submitList(state.postList)
ListAdapter won’t work without calling .toList()
either state.postList
or when passing it to state WordPressPostsState.FetchSuccess
in ViewModel