Vue v3 docs shows an example of watching multiple refs with a single watcher by passing an array as an argument
Can I (and how) use similar approach to watch ref and reactive object at the same time with a single watcher ?
const state = reactive({
postPerPage: 10,
currentPage: 1,
});
const posts = ref([]);
const currentPosts = ref([]);
watch(
() => posts.value, // store value in currentPosts when the posts.value is updated (get data from api)
() => {
currentPosts.value = getCurrentPost();
}
)
watch(
() => {
return { ...state };
}
() => {
currentPosts.value = getCurrentPost();
}
)