angular / angular/components

MdAutocompleteTrigger writeValue is asynchronous

Ouverte
#3,250 1 commentaire 4 réactions 0 personnes assignées Voir sur GitHub
area: material/autocomplete P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

#### 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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par src/lib/autocomplete/autocomplete-trigger.ts, en particulier writeValue et l'appel Promise.resolve mentionné dans l'issue. Reproduisez le comportement en mettant à jour un formControl avec setValue et en vérifiant quand la valeur de l'input change. Le travail est considéré comme terminé lorsque le comportement synchrone demandé est résolu ou que le comportement asynchrone est explicitement documenté.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.