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

refactor: perform shallow diff to avoid unexpected changed events #11

Closed
wants to merge 3 commits into from

Conversation

Aarebecca
Copy link
Contributor

目前 graphlib 没有提供基本的 diff 机制,即如果更新前后的值是完全一样的,也会抛出 changed 事件。

这个 PR 提供了一个基本的快速比较,当深度不超过 3 时,执行深度比较。超过3时,与原逻辑保持一致。

以此避免大部分场景下的非预期 changed 事件抛出

@hustcc
Copy link
Member

hustcc commented Jan 15, 2024

考虑到几个原则,这个 PR 可以先 hold 住:

  1. 越底层的依赖,规则需要约简单明了,graphlib 属于非常底层的数据结构依赖,不适宜增加额外为了性能的规则
  2. 深度 3 为临界,做不同的判断逻辑,难以解释

这就像之前 G2 有一个内置规则,当数据第一条为日期时,数据判定为日期类型,然后这个内置逻辑带来大量的答疑,不如明确告诉用户,如果要设置日期,不如明确告诉默认都是 string,如果要设置为日期类型,那么就设置 scale 为 date 类型,开发者不怕麻烦,怕的是不明确,或者需要了解代码里面的不符合直觉的逻辑。

@hustcc hustcc closed this Dec 10, 2024
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

Successfully merging this pull request may close these issues.

2 participants