@yyx990803 yyx990803 released this Jul 1, 2016 · 542 commits to dev since this release

Assets 2

Note

Vuex 1.0 marks a stable version with small breaking changes from 0.6~0.8, but should be a relatively easy upgrade for current users.

There are some bigger breaking changes (also big improvements) planned for 2.0 here. Both 1.0 and 2.0 will be maintained in parallel for a reasonable amount of time.

New

  • Nested modules:

    A module can in turn contain sub-modules, so a module can be defined as:

    type Module = {
      state?: { [key: string]: any },
      mutations?: { [key: string]: Function },
      modules?: { [key: string]: Module }
    }

    Thanks to @ktsn for implementing this feature.

  • New method: store.replaceState(state)

    Allows explicitly replacing the store's root state. Note this should only be used for state snapshot restoration / time-travel purposes.

  • The store instance is now also an event emitter with on, off, once and emit methods.

Breaking Changes

  • Middlewares are replaced by plugins. A plugin is simply a function that receives the store as the only argument, and can listen to the mutation event on the store:

    const myPlugins = store => {
      store.on('mutation', (mutation, state) => {
        // ...
      })
    }

    For more details, see the updated docs.

  • Object style dispatch fix: in the docs, Object style dispatch was described as sending the dispatched object into the mutation handlers as the second argument, but in previous versions the implementation was incorrect. This caused confusions such as #184. In 1.0 it's been fixed to reflect what was described in the docs, however this technically is a breaking change.