Skip to content

馃殌 Release 0.0.5

Compare
Choose a tag to compare
@posva posva released this 20 Jan 18:29

BREAKING CHANGES

After taking a deeper look at what is necessary for SSR, a few things had to change:

  • Actions are no longer just functions, they must be attached to the store by being passed directly to createStore and they are called as methods of the store (e.g. store.reset())
  • createStore now takes an object instead of positional arguments
// before
export const useMainStore = createStore(
  // id
  'main',
  // state
  () => ({ counter: 0 }),
  // getters
  {
    doubleCount: state => state.counter * 2,
  }
)

export function reset() {
  const store = useMainStore()
  store.state.counter = 0
}
// now
export const useMainStore = createStore({
  id: 'main',
  state: () => ({ counter: 0 }),
  getters: {
    doubleCount: state => state.counter * 2,
  },
  actions: {
    reset() {
      this.state.counter = 0
    },
  },
})
  • feat: allow using getters in other getters (859eeb3)
  • feat: allow empty state option to make it easy to group stores (810e0f0)
  • feat: add nuxt module (4c0ef7a)
  • feat: allow passing the req to useStore (f250622)
  • fix: bind the actions to the store (5e262da)
  • feat: allow useStore to be called within a store (fdf6b45)
  • feat: handle SSR state hydration (2998d53)
  • feat: state hydration (db72247)
  • feat: export types, support state hydration (89996ed)