MdAutocompleteTrigger writeValue is asynchronous
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 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 调用。通过使用 setValue 更新 formControl 并检查 input 值何时发生变化来复现该行为。完成的标准是所请求的同步行为已解决,或异步行为已得到明确记录。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100