yarn vuex 1.0.0-rc

latest releases: 4.1.0, 4.0.2, 4.0.1...
7 years ago

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.

Don't miss a new vuex release

NewReleases is sending notifications on new releases.