Last active
August 20, 2020 06:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('π', 'π') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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