vuex-immutable-replace-state
Vuex replace state plugin to correctly handle state replacement when using immutables states
Problem
Any plugin that uses Store.replaceState
like vuex-persistedstate or SSR like Nuxt are most of the time using JSON.stringify on the state
. All immutable types support a toJSON method what will be called when the state
is stringified. The problem is only when Store.replaceState you state will not have any immutable anymore, just object's, array's etc. what means that you can't call any immutable methods. This plugin tries to solve this problem.
Requirements
Installation
# yarn $ yarn add vuex-immutable-replace-state# npm $ npm install vuex-immutable-replace-state
Usage
options object
property | type | version | default | description |
---|---|---|---|---|
deep |
boolean | false |
^1.1.0 | if set to true it will do a deep replace of immutables |
By default it will only replace the first level of the state
//defaultconst state = todo: //will only work with {deep: true}const state = today: done: todo:
Examples
;; const store = state: todo: //this is important plugins: //first ;
when working with modules {deep: true}
is required
;; const store = state: todo: //this is important module: a: state: plugins: //deep true ;