MdAutocompleteTrigger writeValue is asynchronous
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
#### Bug, feature request, or proposal:
Request for change (RFC)
#### What is the expected behavior?
The MdAutocompleteTrigger writeValue ValueAccesor method should be synchronous.
#### What is the current behavior?
The MdAutocompleteTrigger writeValue ValueAccesor method is asynchronous.
#### What are the steps to reproduce?
Simply implement the autocomplete and try to detect a change being reflected within the view upon updating the `formControl` through `setValue`.
Doing this requires a `setTimeout` coupled with wrapping the body of the `it` statement with `async(() => { ... })` when writing unit tests. If you wish to detect the change being relayed to the input `value`.
This is caused by the fact that (I assume) the writeValue wraps the `_setTriggerValue` method in a `Promise.resolve(...)`: https://github.com/angular/material2/blob/master/src/lib/autocomplete/autocomplete-trigger.ts#L179
#### What is the use-case or motivation for changing an existing behavior?
The motivation for this RFC is the fact that it complicates testing. If their are valid reasons to make the autocomplete trigger asynchronous then that's fine, but the documentation should reflect this fact.
#### Which versions of Angular, Material, OS, browsers are affected?
2.0.0-beta.2
Guía de contribución
Línea de trabajo
Comienza con src/lib/autocomplete/autocomplete-trigger.ts, especialmente con writeValue y la llamada Promise.resolve mencionada en el issue. Reproduce el comportamiento actualizando un formControl con setValue y comprobando cuándo cambia el valor del input. Se considera completado cuando el comportamiento síncrono solicitado está resuelto o el comportamiento asíncrono está documentado explícitamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- frontend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100