MdAutocompleteTrigger writeValue is asynchronous
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
#### 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
Beitragsleitfaden
Rechercherichtung
Beginne mit src/lib/autocomplete/autocomplete-trigger.ts, insbesondere mit writeValue und dem im Issue referenzierten Aufruf Promise.resolve. Reproduziere das Verhalten, indem du ein formControl mit setValue aktualisierst und überprüfst, wann sich der Eingabewert ändert. Als erledigt gilt, dass das angeforderte synchrone Verhalten behoben oder das asynchrone Verhalten ausdrücklich dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- frontend
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100