- onBefore 핸들러 추가
- 타입 개선
- 리드미 개선
// Promises chaining
startLoadingIndicator();
getAvatarUrlfromGithub(USER_NAME)
.then(showAvatar)
.then((githubUser) => console.log(`avatar_url: ${githubUser.avatar_url}`))
.catch((error) => console.error(error))
.finally(endLoadingIndicator);
// with asyncWave
asyncWave<GithubUser>([USER_NAME, getAvatarUrlfromGithub], {
onBefore: () => {
startLoadingIndicator();
},
onSuccess: async (githubUser) => {
await showAvatar(githubUser); // 핸들러 내부 에러도 캐치됩니다!
console.log(`avatar_url: ${githubUser.avatar_url}`);
},
onError: (error) => {
console.error(error);
},
onSettled: () => {
endLoadingIndicator();
},
});