Closed Sunyuwumengsheng closed 2 years ago
I'm not sure I understand your question. One opportunity for improvement is to make articles
and banner
derived props like this:
data class YourState(
val bannerRequest: Async<BannerRequest> = Uninitialized,
val articleRequest: Async<ArticleRequest> = Unitialized,
) : MavericksState {
val banner = bannerRequest() ?: emptyList()
val article = articleRequest()?.data ?: article
}
Then your execute can look like
suspend {
api.getArticle(page)
}.execute { copy(articleRequest = it) }
sorry my english is not good
The effect I want is something like this
suspend { zip(api.getBanner(), api.getArticle(page)) }.execute { copy( bannerRequest= it.bannerRequest articleRequest = it.articleRequest ) }
Sounds like you got it working 😄
I have two requests A and B. When the page is initialized, I need to request both A and B, and then I need to request B separately.I do now, but think it's problematic.
init { getBanner() getArticle(0) }