MdAutocompleteTrigger writeValue is asynchronous
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
#### 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
コントリビューションガイド
調査の方向性
src/lib/autocomplete/autocomplete-trigger.ts から始め、特に writeValue と issue で参照されている Promise.resolve の呼び出しを確認してください。formControl を setValue で更新し、input の値がいつ変化するかを確認して、この動作を再現してください。要求された同期的な動作が解決されるか、非同期の動作が明示的に文書化されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100