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(wepy): $dirty 调用时机由 Observer 改到 Watcher,解耦 RenderWatcher 和 O… #2801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nishino-tsukasa
Copy link
Collaborator

Observer 之所以会引用 vm,是为了响应数据被修改时,把修改信息放入 vm.$dirty。
其实可以换个思路。把修改信息通过 notify 往上传给Watcher,由Watcher调用 vm.$dirty。

除了解决 GC 之外,还解决了另一个问题,响应数据和关联的第一个 vm 耦合。
举个例子,有一个 obj。
pageA.data.a = obj。pageB.data.b = obj。
obj.x = 123,只有页面 A 会更新,而页面 B 无法更新,因为 obj 引用的 vm 是 PagaA

Checklist
  • npm run test passes
  • tests and/or benchmarks are included
  • cases or donate is changed or added
  • documentation is changed or added

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 35.409% when pulling 17d0ac6 on refactor/dirtyData into 96ab19e on master.

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

Successfully merging this pull request may close these issues.

None yet

3 participants