Commit Graph

116 Commits

Author SHA1 Message Date
Thorsten Lünborg cd7c887b75
fix(reactivity): ensure watch(Effect) can run independent of unmounted instance if created in a detatched effectScope (fix #7319) (#7330)
* fix(reactivity): ensure watch(Effect) can run independent of unmounted instance if created in a detatched effectScope

* test: use separate counters for each watcher to make test more robust
2023-01-09 15:20:21 +01:00
webfansplz 11bd8db768
chore(types): remove unnecessary type assertions (#7032) 2022-11-14 01:44:06 -05:00
Thorsten Lünborg 5dc593ba28
fix(watch): for immediate watch with single source, ensure cb is called with undefined as oldValue (#7075)
fix: #7074
2022-11-09 18:19:35 -05:00
Evan You 23e85e21a5 fix(watch): ensure oldValue in multi-source watcher is always an array
fix #7070
2022-11-09 20:50:02 +08:00
webfansplz 0e0976168f
fix(ssr/watch) flush: sync watchers should work in ssr (#6139)
fix #6013
2022-10-26 06:30:15 -04:00
Thorsten Lünborg bc167b5c6c
fix(runtime-core): watching multiple values - handle `undefined` as initial values (fix: #5032) (#5033) 2022-10-20 21:45:05 +02:00
Evan You 78c199d6db fix(watch): flush:pre watchers should not fire if state change causes
owner component to unmount

fix #2291
2022-08-15 19:00:55 +08:00
edison 220f255fe9
fix(watch): fix watching multiple sources containing shallowRef (#5381)
fix #5371
2022-05-12 20:20:04 -04:00
Evan You 74d2a76af6 fix(watch): fix flush: pre watchers triggered synchronously in setup
fix #5721
2022-04-15 18:08:44 +08:00
Evan You 7efb9dba30 refactor: remove use of Object.assign
TS already transpiles spread to Object.assign with target:es2016
2022-04-12 15:22:11 +08:00
Evan You 9fda9411ec feat(reactivity): add isShallow api 2022-01-18 09:22:41 +08:00
Evan You ce49fdf999 refactor: more readable type names for watch cleanup function 2022-01-12 22:07:47 +08:00
Evan You 87c86e4cc2 refactor: ensure ssr branches are included in esm-bundler build 2021-09-23 15:02:19 -04:00
Yang Mingshan 11a2098a69
fix(watch): remove redundant parameter default value (#4565) 2021-09-21 12:32:12 -04:00
Evan You d87d059ac1 feat(runtime-core): watchSyncEffect 2021-07-20 16:49:54 -04:00
Evan You bc7f9767f5 fix(watch): ensure watchers respect detached scope
fix #4158
2021-07-20 14:32:17 -04:00
Evan You 47f488350c chore: run updated prettier 2021-07-19 18:24:18 -04:00
ioslh 20b6619793
fix(ssr): update initial old value to watch callback in ssr usage (#4103) 2021-07-19 17:13:37 -04:00
Evan You 42ace9577d feat: watchPostEffect 2021-07-16 14:30:49 -04:00
Anthony Fu f5617fc3bb feat(reactivity): new effectScope API (#2195) 2021-07-16 14:30:49 -04:00
Evan You 87f69fd0bb perf(reactivity): improve reactive effect memory usage (#4001)
Based on #2345 , but with smaller API change

- Use class implementation for `ReactiveEffect`
- Switch internal creation of effects to use the class constructor
- Avoid options object allocation
- Avoid creating bound effect runner function (used in schedulers) when not necessary.
- Consumes ~17% less memory compared to last commit
- Introduces a very minor breaking change: the `scheduler` option passed to `effect` no longer receives the runner function.
2021-07-16 14:30:49 -04:00
Evan You 2937530bef fix(v-model): handle mutations of v-model bound array/sets
fix #4096
2021-07-15 12:14:19 -04:00
Evan You fddef8bb74 chore: remove unnecessary casting 2021-06-26 21:35:25 -04:00
Evan You 9acc9a1fa8 fix(watch): avoid traversing objects that are marked non-reactive
e.g. Vue public instances
2021-06-02 15:51:27 -04:00
Evan You 1ff06376ff chore: type fix 2021-05-27 20:58:27 -04:00
Evan You 1526f94edf fix(watch): should not leak this context to setup watch getters
ref #3603
2021-05-25 11:10:11 -04:00
AbaAba~ e7300eb479
fix(runtime-core): watching multiple sources: computed (#3066)
fix #3068
2021-05-07 18:03:35 -04:00
Evan You 98bc9a26e9 wip: more compat tweaks 2021-04-22 09:49:25 -04:00
Evan You 62b8f4a39c fix(watch): avoid traversing non-plain objects 2021-04-20 17:13:58 -04:00
Evan You 115372dd5b wip: refactor deprecations into a single file 2021-04-12 18:47:50 -04:00
Evan You a2f441dc0e wip: refactor compat check utils 2021-04-09 23:51:50 -04:00
Evan You 7a25cbb7a7 wip: fix compat utils usage 2021-04-09 23:21:54 -04:00
Evan You 1c2c77eb9f wip: apply compat enabled flags to currently implemented features 2021-04-07 16:19:25 -04:00
Evan You 208bef5d97 wip: watch array compat 2021-04-07 16:19:25 -04:00
Evan You 870f2a7ba3 fix(watch): this.$watch should support watching keypath 2021-04-07 16:19:04 -04:00
TJ Koblentz e4b5fccd0c
fix(ssr): watchEffect onInvalidate runner initialization (#3323)
close #3322
2021-03-25 11:17:57 -04:00
edison eb1fae63f9
fix(runtime-core): handle error in async watchEffect (#3129) 2021-03-23 10:20:52 +01:00
edison ec8fd10cec
fix(runtime-core): instanceWatch should pass `this.proxy` to source as the first argument (#2753) 2021-02-09 08:00:32 +01:00
Yang Mingshan e109f7b898
chore: remove overloads numbers in comments (#2976) 2021-02-04 14:34:40 +08:00
Zcating d2d27b2e66
types(watch): better typing when watching multiple sources (#2425) 2020-12-04 16:32:26 -05:00
Thorsten Lünborg 735af1c7b7
fix(runtime-core): ensure watchers are always registered to correct instance owner (#2495)
close: #2381
2020-11-27 09:31:50 -05:00
Pick 9b34f915ab
refactor(runtime-core): simplify deep watch traverse (#2212) 2020-10-13 16:06:36 -04:00
Pick e4a5387435
refactor(runtime-core): refactor watch typing (#2191) 2020-10-13 15:45:17 -04:00
Evan You 390589ec6d fix(reactivity): should not trigger watch on computed ref when value is unchanged
fix #2231
2020-10-06 18:16:20 -04:00
Evan You 49bb44756f refactor: watch APIs default to trigger pre-flush
BREAKING CHANGE: watch APIs now default to use `flush: 'pre'` instead of
`flush: 'post'`.

  - This change affects `watch`, `watchEffect`, the `watch` component
    option, and `this.$watch`.

  - As pointed out by @skirtles-code in
    [this comment](https://github.com/vuejs/vue-next/issues/1706#issuecomment-666258948),
    Vue 2's watch behavior is pre-flush, and the ecosystem has many uses
    of watch that assumes the pre-flush behavior. Defaulting to post-flush
    can result in unnecessary re-renders without the users being aware of
    it.

  - With this change, watchers need to specify `{ flush: 'post' }` via
    options to trigger callback after Vue render updates. Note that
    specifying `{ flush: 'post' }` will also defer `watchEffect`'s
    initial run to wait for the component's initial render.
2020-09-17 23:17:21 -04:00
Evan You 0124eacc91 refactor(reactivity): refactor iteration key trigger logic + use more robust Map/Set check 2020-09-14 11:26:34 -04:00
Yang Mingshan 10293c7a18
fix(watch): traverse refs in deep watch (#1939)
ref #1900
2020-08-23 14:41:11 -04:00
Evan You 611437a3fe fix(runtime-core/scheduler): allow component render functions to trigger itself
fix #1801
2020-08-13 17:42:47 -04:00
Evan You 3692f2738f refactor(runtime-core/scheduler): dedicated preFlush queue
properly fix #1763, #1777, #1781
2020-08-05 10:55:23 -04:00
Evan You fce2689ff1 fix(watch): should trigger watcher callback on triggerRef when watching ref source
fix #1736
2020-07-30 18:29:38 -04:00