angular / angular/components

MdAutocompleteTrigger writeValue is asynchronous

Aperta
#3,250 1 commento 4 reazioni 0 assegnatari Vedi su GitHub
area: material/autocomplete P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da src/lib/autocomplete/autocomplete-trigger.ts, in particolare da writeValue e dalla chiamata Promise.resolve menzionata nell'issue. Riproduci il comportamento aggiornando un formControl con setValue e verificando quando cambia il valore dell'input. Il lavoro è completato quando il comportamento sincrono richiesto è risolto oppure il comportamento asincrono è documentato esplicitamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.