Commit Graph

54 Commits

Author SHA1 Message Date
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
HeYunfei
b5b103a736
chore(types): delete @ts-ignore or use @ts-expected-error instead (#3669)
Co-authored-by: heyunfei.i <heyunfei.i@bytedance.com>
2022-05-11 20:40:59 -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
ae4b0783d7 chore: update repo references 2022-01-18 16:43:59 +08: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
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
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
870f2a7ba3 fix(watch): this.$watch should support watching keypath 2021-04-07 16:19:04 -04:00
Evan You
d5824b97c5 fix(runtime-core): should not track deps in pre flush watcher callbacks
fix #2728
2021-03-26 15:52:49 -04: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
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
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
3810de7d6b fix(reactivity): effect shoud only recursively self trigger with explicit options
fix #2125
2020-09-16 10:52:31 -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
7454e2a52b build(deps): upgrade to TypeScript 4 2020-08-20 17:48:28 -04:00
Evan You
223f180529 test(watch): add same value skipping trigger test 2020-08-14 17:35:49 -04:00
HcySunYang
caccec3f78
fix(runtime-core/scheduler): sort postFlushCbs to ensure refs are set before lifecycle hooks (#1854)
fix #1852
2020-08-14 09:50:23 -04:00
Evan You
a0e34cee4a fix(watch): exhaust pre-flush watchers + avoid duplicate render by pre-flush watchers
close #1777
2020-08-04 13:20:23 -04:00
Evan You
d4c17fb48b fix(watch): pre-flush watcher watching props should trigger before component update
fix #1763
2020-08-03 16:49:30 -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
Evan You
5c74243211 test: move mockWarn into setup files 2020-07-27 22:58:51 -04:00
Tan Li Hau
288b4eab9e
fix(watch): fix watching reactive array (#1656)
fixes #1655
2020-07-20 12:39:22 -04:00
Carlos Rodrigues
8facaefcc3
fix(watch): callback not called when using flush:sync (#1633) 2020-07-19 13:30:24 -04:00
Evan You
341b30c961 fix(watch): post flush watchers should not fire when component is unmounted
fix #1603
2020-07-17 11:17:29 -04:00
Yang Mingshan
ba62ccd55d
feat(watch): support directly watching reactive object in multiple sources with deep default (#1201) 2020-05-18 11:02:51 -04:00
Evan You
6b33cc4229 feat(watch): support directly watching reactive object with deep default
Also warn invalid watch sources

close #1110
2020-05-04 09:27:28 -04:00
Carlos Rodrigues
99fd158d09
fix(watch): fix deep watchers on refs containing primitives (#984) 2020-04-17 09:55:41 -04:00
Yang Mingshan
14908f2734
chore: prefer const (#865) 2020-03-23 11:11:00 -04:00
djy0
19a799c28b
fix(runtime-core): make watchEffect ignore deep option (#765) 2020-02-24 18:03:02 +01:00
Evan You
99a2e18c97 feat(runtime-core): add watchEffect API
BREAKING CHANGE: replae `watch(fn, options?)` with `watchEffect`

    The `watch(fn, options?)` signature has been replaced by the new
    `watchEffect` API, which has the same usage and behavior. `watch`
    now only supports the `watch(source, cb, options?)` signautre.
2020-02-22 08:19:10 +01:00
Evan You
9571ede84b refactor(watch): adjsut watch API behavior
BREAKING CHANGE: `watch` behavior has been adjusted.

    - When using the `watch(source, callback, options?)` signature, the
      callback now fires lazily by default (consistent with 2.x
      behavior).

      Note that the `watch(effect, options?)` signature is still eager,
      since it must invoke the `effect` immediately to collect
      dependencies.

    - The `lazy` option has been replaced by the opposite `immediate`
      option, which defaults to `false`. (It's ignored when using the
      effect signature)

    - Due to the above changes, the `watch` option in Options API now
      behaves exactly the same as 2.x.

    - When using the effect signature or `{ immediate: true }`, the
      intital execution is now performed synchronously instead of
      deferred until the component is mounted. This is necessary for
      certain use cases to work properly with `async setup()` and
      Suspense.

      The side effect of this is the immediate watcher invocation will
      no longer have access to the mounted DOM. However, the watcher can
      be initiated inside `onMounted` to retain previous behavior.
2020-02-17 23:16:58 -05:00
Evan You
c6a9787941 fix(types): ensure correct oldValue typing based on lazy option
close #719
2020-02-13 12:09:13 -05:00
Eduardo San Martin Morote
5742a0b826
fix(runtime-core/watch): trigger watcher with undefined as initial value (#687)
Fix #683
2020-02-04 09:59:04 -05:00
Evan You
2569890e31 refactor: move mockWarn utility to @vue/shared
close #652
2020-01-22 09:29:45 -05:00
Rustin
787ac5f74e test(runtime-core): modify test case to set different value (#620) 2020-01-20 09:43:58 -05:00
Evan You
3deb20df63 feat(watch): warn when using lazy with simple callback 2019-12-18 11:54:12 -05:00
Yang Mingshan
c2c9c2b57e fix(watch): ignore lazy option in simple watch (#546)
* fix(watch): ignore lazy option in simple watch

* test: ignore lazy option in simple watch
2019-12-18 11:46:59 -05:00
Evan You
89a187b895 refactor(reactivity): separate track and trigger operation types 2019-12-03 11:30:24 -05:00
Adam Lewkowicz
555e3be69d types(watch): allow readonly arrays for watching multiple sources (#281) 2019-10-15 16:44:14 -04:00
Evan You
6b3ad95fa4 fix(watch): type inference for computed refs 2019-10-14 12:15:09 -04:00
Evan You
b40b7356ef test: tests for lifecycle api 2019-08-28 12:13:36 -04:00
Evan You
2b6ca9a7b6 test: fix deep watch for Map/Set 2019-08-27 15:01:01 -04:00
Evan You
62e07a1b7e test: coverage 2019-08-27 14:42:05 -04:00
Evan You
7ecdc79d5e test: finish tests for watch api 2019-08-27 11:35:22 -04:00