I want to load a user profile before doing something on the page, but the entire user profile consists of different parts that are loaded with several HTTP requests.
While I load the user profile sequentially (one by one)
type alias CompanyInfo =
{ name: String
, address: ...
, phone: String
, ...
}
type alias UserProfile =
{ userName: String
, companyInfo: CompanyInfo
, ...
}
Cmd.batch
[ loadUserName userId LoadUserNameFail LoadUserNameSuccess
, loadCompanyInfo userId LoadCompanyInfoFail LoadCompanyInfoSuccess
...
]
But it is not very effective. Is there an easy way how to execute a bunch of Http requests and return only one full value?
Something like that
init =
(initialModel, loadUserProfile userId LoadUserProfileFail LoadUserProfileSuccess)
....
source
share