wepy icon indicating copy to clipboard operation
wepy copied to clipboard

refactor(wepy): $dirty 调用时机由 Observer 改到 Watcher,解耦 RenderWatcher 和 O…

Open nishino-tsukasa opened this issue 2 years ago • 1 comments

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
  • [x] npm run test passes
  • [ ] tests and/or benchmarks are included
  • [ ] cases or donate is changed or added
  • [ ] documentation is changed or added

nishino-tsukasa avatar May 22 '22 16:05 nishino-tsukasa

Coverage Status

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

coveralls avatar May 22 '22 16:05 coveralls