make DataProvider an interface

Đang mở
#7,326 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #7351 của @antdking — đã đóng, không merge

Đánh giá

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

Hướng nghiên cứu

Xác định alias kiểu DataProvider và kiểm tra các cách sử dụng của nó trong các hook cũng như các typing của resource/model. Kiểm tra việc chuyển nó thành interface ảnh hưởng thế nào đến việc truyền generic và typing của injectable, sau đó xác thực hành vi bằng demo được đề xuất; hoàn tất nghĩa là mối liên kết từ resourceName đến RaRecord hoạt động xuyên suốt các hook mà không cần các generic wrapper tường minh.

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

Mô tả

Is your feature request related to a problem? Please describe.
Currently, to extend the DataProvider, we have to be very explicit about generics, and do a fair amount of hackery to expose Models/Resources everywhere.
The aim here is to build an abstraction around the pieces in react-admin, to make wiring up APIs/Models/Views a lot more seamless within editor environments (fully static with plain JS for users).

Describe the solution you'd like
Currently, DataProvider is a TypeAlias, which are not injectable.
By allowing us to inject the DataProvider, we can cause resourceName -> RaRecord associations to propagate to all the hooks (useGetList('cats') should automatically find my Cat Model).

For now, changing it from type to interface might be enough, however I'm unsure of the fallout. I'll spin up a PR with a Demo to verify how it all goes, and so you have something physical to see.

I suspect this will be beneficial for the no-code project, however I've yet to do a dive into what that is in detail.

Describe alternatives you've considered
Wrapping + explicit types == Code too noisy

Additional context
n/a

Ngôn ngữ chính
TypeScript
Star
27k
Fork
5.5k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
34

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của marmelab/react-admin

Tất cả issue của marmelab/react-admin

Issue tương tự

Thêm issue về TypeScript

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.