Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traducir Practical observable usage #288

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions aio/content/guide/practical-observable-usage.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Practical observable usage

Here are some examples of domains in which observables are particularly useful.

## Type-ahead suggestions

Observables can simplify the implementation of type-ahead suggestions. Typically, a type-ahead has to do a series of separate tasks:

* Listen for data from an input.
* Trim the value (remove whitespace) and make sure it’s a minimum length.
* Debounce (so as not to send off API requests for every keystroke, but instead wait for a break in keystrokes).
* Don’t send a request if the value stays the same (rapidly hit a character, then backspace, for instance).
* Cancel ongoing AJAX requests if their results will be invalidated by the updated results.

Writing this in full JavaScript can be quite involved. With observables, you can use a simple series of RxJS operators:

<code-example path="practical-observable-usage/src/typeahead.ts" header="Typeahead"></code-example>

## Exponential backoff

Exponential backoff is a technique in which you retry an API after failure, making the time in between retries longer after each consecutive failure, with a maximum number of retries after which the request is considered to have failed. This can be quite complex to implement with promises and other methods of tracking AJAX calls. With observables, it is very easy:

<code-example path="practical-observable-usage/src/backoff.ts" header="Exponential backoff"></code-example>
22 changes: 11 additions & 11 deletions aio/content/guide/practical-observable-usage.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Practical observable usage

Here are some examples of domains in which observables are particularly useful.
Aquí tienes algunos ejemplos de dominios en los que las observables son particularmente útiles.

## Type-ahead suggestions
## Sugerencias de autocompletado

Observables can simplify the implementation of type-ahead suggestions. Typically, a type-ahead has to do a series of separate tasks:
Las observables pueden simplificar la implementación de las sugerencias del autocompletado. Normalmente, un autocompletado realiza una serie de tareas:

* Listen for data from an input.
* Trim the value (remove whitespace) and make sure it’s a minimum length.
* Debounce (so as not to send off API requests for every keystroke, but instead wait for a break in keystrokes).
* Don’t send a request if the value stays the same (rapidly hit a character, then backspace, for instance).
* Cancel ongoing AJAX requests if their results will be invalidated by the updated results.
* Recibe la información desde una entrada.
* Recorta el valor (eliminando espacios) y se asegura de que tiene una longitud mínima.
* Hacer debounce (no manda solicitudes a la API por cada tecla pulsada, sino que espera una parada entre letras).
* No se manda una solicitud si el valor es el mismo (por ejemplo, teclear un caracter y, al momento, borrarlo)
* Cancelar solicitudes AJAX activas si sus resultados van a ser invalidados por los resultados actualizados siguientes.

Writing this in full JavaScript can be quite involved. With observables, you can use a simple series of RxJS operators:
Escribir esto íntegramente en JavaScript puede ser bastante tedioso. Con las observables, puedes utilizar una serie de simples operadores RxJS:

<code-example path="practical-observable-usage/src/typeahead.ts" header="Typeahead"></code-example>

## Exponential backoff
## Retroceso exponencial

Exponential backoff is a technique in which you retry an API after failure, making the time in between retries longer after each consecutive failure, with a maximum number of retries after which the request is considered to have failed. This can be quite complex to implement with promises and other methods of tracking AJAX calls. With observables, it is very easy:
El retroceso exponencial es una técnica en la cual vuelves a intentar la API después de un fracaso, haciendo que el tiempo entre intentos tras cada fracaso consecutivo sea cada vez más largo, con un número máximo de intentos hasta que consideras que la solicitud ha sido fallida. Esto puede ser bastante complejo de implementar con promesas y otros métodos de tracking que AJAX emplea. Con observables, es muy fácil:

<code-example path="practical-observable-usage/src/backoff.ts" header="Exponential backoff"></code-example>