Created
July 14, 2020 07:57
-
-
Save sonicoder86/a4196385d945d1375171df105fc6c6e8 to your computer and use it in GitHub Desktop.
You Might Not Need Vuex - part 3
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, provide, inject } from 'vue'; | |
export const stateSymbol = Symbol('state'); | |
export const createState = () => reactive({ counter: 0 }); | |
export const useState = () => inject(stateSymbol); | |
export const provideState = () => provide( | |
stateSymbol, | |
createState() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment