Skip to content

Instantly share code, notes, and snippets.

@mvsde
Last active August 20, 2020 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvsde/9e7f5243e4e3536c5d2010c2e77ba6c6 to your computer and use it in GitHub Desktop.
Save mvsde/9e7f5243e4e3536c5d2010c2e77ba6c6 to your computer and use it in GitHub Desktop.
Basic reactive store with Vue 3: https://v3.vuejs.org/api/basic-reactivity.html
import store from './store.js'
console.log(store.state.hello) // '🌍'
store.greet('🌌')
console.log(store.state.hello) // '🌌'
console.log(store.state.cool) // Set('🍍')
store.addCool('🍌')
console.log(store.state.cool) // Set('🍍', '🍌')
import { reactive } from 'vue'
export default {
state: reactive({
hello: '🌍',
cool: new Set('🍍')
}),
greet (name) {
this.state.hello = name
},
addCool (stuff) {
this.state.cool.add(stuff)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment