Skip to content

Instantly share code, notes, and snippets.

@ktsn
Created September 7, 2018 03:16
Show Gist options
  • Save ktsn/09746ec0179a3100c6a829f8db97a838 to your computer and use it in GitHub Desktop.
Save ktsn/09746ec0179a3100c6a829f8db97a838 to your computer and use it in GitHub Desktop.
Light-weight reactive store for Vue.js
class Store<S> {
private vm: Vue
constructor(initialState: S) {
this.vm = new Vue({
data: initialState
})
}
get state(): S {
return this.vm.$data as S
}
}
interface AppState {
// ...
}
export default class AppStore extends Store<AppState> {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment