Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created October 29, 2020 19:38
Show Gist options
  • Save shershen08/aad23cb695db4299509494b5f9c9659b to your computer and use it in GitHub Desktop.
Save shershen08/aad23cb695db4299509494b5f9c9659b to your computer and use it in GitHub Desktop.
vuex4 + filtering stuff in component
setup(props) {
const store = useStore()
const user = computed(() => {
return store.getters.authUser
})
const posts = computed(() => {
return store.getters.posts
})
const userPosts = computed(() => {
//console.log(user, posts)
const res = []
for (const key in Object.keys(posts.value)) {
res.push(posts[key])
}
return res
//.value.filter(post => post.userId == user.userId)
})
const userPostsCount = watch(userPosts, (userPosts) => userPosts.lenth)
return {userPosts, user, userPostsCount}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment