angular / angular/components

MdAutocompleteTrigger writeValue is asynchronous

Đang mở
#3,250 1 bình luận 4 reaction 0 người được giao Xem trên GitHub
area: material/autocomplete P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với src/lib/autocomplete/autocomplete-trigger.ts, đặc biệt là writeValue và lệnh gọi Promise.resolve được đề cập trong issue. Tái hiện hành vi bằng cách cập nhật một formControl với setValue và kiểm tra thời điểm giá trị của input thay đổi. Được xem là hoàn tất khi hành vi đồng bộ được yêu cầu đã được giải quyết hoặc hành vi bất đồng bộ được ghi tài liệu một cách rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.