This repository was archived by the owner on Mar 18, 2026. It is now read-only.
refactor(wepy): $dirty 调用时机由 Observer 改到 Watcher,解耦 RenderWatcher 和 O…#2801
Open
nishino-tsukasa wants to merge 1 commit into
Open
refactor(wepy): $dirty 调用时机由 Observer 改到 Watcher,解耦 RenderWatcher 和 O…#2801nishino-tsukasa wants to merge 1 commit into
nishino-tsukasa wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testpasses