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

watchEffect is not same as vue3 watchEffect? #633

Closed
gitHber opened this issue Jan 16, 2021 · 3 comments
Closed

watchEffect is not same as vue3 watchEffect? #633

gitHber opened this issue Jan 16, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@gitHber
Copy link

gitHber commented Jan 16, 2021

setup() {
    const num = ref(0);
    watchEffect(() => {
      console.log("num change will not trigger this effect");
      num.value = 1;
    });
    setTimeout(() => {
      num.value++;
    }, 5000);
    return {
      num
    };
  }

in vue3, it's right, watchEffect only triggered by value getter(not setter), in composition-api, it will triggered by value setter which means it's not right

vue3-demo https://stackblitz.com/edit/vue-qfisdz
sorry, I did't create a demo for @vue/composition-api.

@pikax pikax added the bug Something isn't working label Jan 16, 2021
@prigaux
Copy link

prigaux commented Feb 1, 2021

NB : this bug breaks the asyncComputed function suggested in foxbenjaminfox/vue-async-computed#104 .

(i'm trying to transition from vue2->vue3 by gradually migrating from "options API" to "composition API" with vue2)

@gitHber
Copy link
Author

gitHber commented Apr 6, 2021

NB : this bug breaks the asyncComputed function suggested in foxbenjaminfox/vue-async-computed#104 .

(i'm trying to transition from vue2->vue3 by gradually migrating from "options API" to "composition API" with vue2)

just for additional, watch api only triggered when watcher value change, but watchEffect api would triggered when watcher value set

@ygj6
Copy link
Member

ygj6 commented Aug 30, 2021

Solved by #786.

@ygj6 ygj6 closed this as completed Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants