Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Created July 14, 2020 07:57
Show Gist options
  • Save sonicoder86/a4196385d945d1375171df105fc6c6e8 to your computer and use it in GitHub Desktop.
Save sonicoder86/a4196385d945d1375171df105fc6c6e8 to your computer and use it in GitHub Desktop.
You Might Not Need Vuex - part 3
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