javascript-tutorial / javascript-tutorial/en.javascript.info
Suggestion for Additions to Article on Promise
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- HTML
- Estrellas
- 25.5k
- Forks
- 4k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
We can add a section for Promises vs Callbacks to show the inherent advantages of Promise:
Like this :
At the simplest level, Promises are just a different way of working with callbacks. However, there are practical benefits to using them.
-
One real problem with callback based asynchronous programming is that it is common to end up with callbacks
inside callbacks inside callbacks, with lines of code so highly indented that it is difficult to read.
Promises allow this kind of nested callback to be re-expressed as a more linear Promise chain that tends to be easier to read and easier to reason about. -
Another problem with callbacks is that they can make handling errors difficult. If an asynchronous function (or an asynchronously invoked callback) throws an exception, there is no way for that exception to propagate back to the initiator of the asynchronous operation.
This is a fundamental fact about asynchronous programming: It breaks exception handling.
The alternative is to meticulously track and propagate errors with callback arguments and return values, but this is tedious and difficult to get right.
Promises help here by standardizing a way to handle errors and providing a way for errors to propagate correctly through a chain of promises.
Promises are therefore a powerful idiom for asynchronous programming.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Abre el artículo sobre Promises al que hace referencia el issue y revisa su explicación existente de la programación asíncrona. Añade una sección específica “Promises vs Callbacks” utilizando los puntos proporcionados sobre anidamiento, legibilidad y propagación de errores, y confirma después que el artículo mantiene la coherencia con el contenido circundante.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100