Skip to content

v1.0.0

Choose a tag to compare

@pimlie pimlie released this 15 Nov 10:46
· 37 commits to master since this release

Release v1.0.0 πŸŽ‰

We are releasing vue-stator v1 as we are introducing some breaking changes:

  • full module support with namespacing
    this breaks the old syntax that required you to pass two arguments. Similar to Vuex, vue-stator now uses slashed namespace paths to e.g. map state, getters and actions.
  • abstracted storage
    You can easily add any storage which has a similar interface as Storage (only the getItem and setItem methods are really required)

See the updated readme for more information

Registering module example

const myModule = {
  state() {
    return {
      myVar: 2
    }
  }
}

const config = {
  state() {
    return {
      rootVar: 1
    }
  },
  modules: {
    'my/module': myModule
  }
}

const stator = createStore(config)

stator.$state.rootVar // => 1
stator.$state.my.module.myVar // => 2

Or you can also register the module dynamically:

const stator = createStore(config)

stator.registerModule(myModule, 'my/module')

Namespacing syntax example

Old syntax:

// store/state.js
export default () => ({
  rootVar: 1,
  my: {
    myVar: 2
  }
})

// store/my.js
export const getters = {
  myGetter(state) {
    return state.myVar
  }
}

// within component.vue
  computed: {
    ...mapGetters(['my', 'myGetter'])
  }

New syntax:

// store/state.js
export default () => ({
  rootVar: 1
})

// store/my.js
export const state = () => ({
  myVar: 2
})

export const getters = {
  myGetter(state) {
    return state.myVar
  }
}

// within component.vue
  computed: {
    ...mapGetters(['my/myGetter'])
  }