#59 SharedList

Đã đóng
%! (template.HTML=4 năm trước cách đây)đang mở bởi ranides · 3 ý kiến

class SharedList will have fields:

  1. source: List
  2. view: PublicList
  3. data: PrivateList

The source one must be hidden from everyone.

PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter.

Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners".

Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.

class SharedList will have fields: 1. source: `List` 2. view: `PublicList` 3. data: `PrivateList` The source one must be hidden from everyone. PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter. Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners". Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.
Đăng nhập để tham gia bình luận.
Không có Milestone
Không có người được phân công
1 tham gia
Đang tải...
Hủy bỏ
Lưu
Ở đây vẫn chưa có nội dung nào.