Callback Hell
getCurrentCity(callback: (error, city: string) => void);getWeatherInfo(city: string, callback: (error, weatherInfo: WeatherInfo) => void);const handleError = error => {
console.error(`Something went wrong but I don't know how to handle it`);
};
getCurrentCity((error, city) => {
if (error != null) {
handleError(error);
return;
}
getWeatherInfo(city, (err, weatherInfo) => {
if (error != null) {
handleError(error);
}
console.log(`${city}: ${weatherInfo.temperature}`);
});
});Closure Cupide
Multi-purpose Error-First Callback
Pas de catch
catchAnnulation
JavaScript Async Libraries
Mis à jour