Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListModule 暴露 event 的必要性? #90

Closed
ScarboroughCoral opened this issue Dec 15, 2023 · 3 comments
Closed

ListModule 暴露 event 的必要性? #90

ScarboroughCoral opened this issue Dec 15, 2023 · 3 comments

Comments

@ScarboroughCoral
Copy link

在看 TodoList example 时发现event产生依赖于TodoListModulecommand,但是 command 实现细节是在remesh 内部的,需要使用者确定command确实对list产生了修改,如果ListModule对外暴露ListChangedEvent、ListItemAddedEvent等事件,外部就确定事件已发生可以直接使用。不知道有没有必要呢?如果有必要的话我想尝试提一下pr~
image

@hourong88
Copy link

hourong88 commented Dec 15, 2023 via email

@Lucifier129
Copy link
Collaborator

@ScarboroughCoral ListModule 不暴露 Event 是已知的问题。最初是添加了 ItemAddedEvent, ItemDeletedEvent, ListChangedEvent 等事件,但后面发现,这些事件无法可靠地触发,因为 SetListCommand 可以将 List 整体替换,其中有些可能是 add 的新元素,有些可能是 delete 了,而有些可能 re-order 了。

这将导致业务逻辑依赖 ItemAddEvent 时,有些不是通过 AddItemCommand 添加的 added items 可能不会触发。

正因如此,remesh 才意欲引入 entity-component-systementity-relationship model 等模型,掌控底层 state 的表征方式,以便得到更可靠的 state related events。

目前的折衷做法是,ListModule 自身不暴露 event,由上层 domain 自己管理自己的 event 并保证它们的可靠性。后续 remesh 升级后或许会克服这类问题。

@ScarboroughCoral
Copy link
Author

好的 确实是这样 了解了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants