AppState Class Contradicts the definition in the official Guide to App Architecture Documentation

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

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

Đá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ái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
android, kotlin
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu bằng cách đọc StateHolder guide và NiaAppState entry point được đề cập trong issue, cùng với các tham chiếu của nó đến UserNewsResourceRepository, NetworkMonitor và TimeZoneMonitor. So sánh phần triển khai với guide và ghi lại liệu thiết kế hiện tại có phải là chủ ý hay không; để được xem là hoàn tất, cần quyết định một định hướng kiến trúc, không chỉ thay đổi code.

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

Mô tả

I noticed the StateHolder guide
describes plain class state holders as UI-only, without business logic. But in the Now in Android code, NiaAppState:

directly references UserNewsResourceRepository, NetworkMonitor, and TimeZoneMonitor (i.e. data layer)

computes derived state related to “unread resources” (some business logic)

is instantiated via remember, not through a ViewModel

So NiaAppState is not a pure “plain class state holder” per the guide. It behaves more like an app-level UI coordinator / state orchestrator, combining UI logic with lightweight access to domain data for navigation and cross-feature state.

Could you clarify:

  1. Was NiaAppState deliberately designed this way (blending data and UI logic) for sample simplicity or is there another architectural reason?

  2. In your view, should some of the data access / business-logic portions be moved to a ViewModel or domain layer instead?

I can also propose a stricter refactoring version that aligns more closely with the guide’s architecture!

Ngôn ngữ chính
Kotlin
Star
22.1k
Fork
4.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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 android/nowinandroid

Tất cả issue của android/nowinandroid

Issue tương tự

Thêm issue về Kotlin

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.