Skip to content

Commit 3fff85f

Browse files
committed
add replace state method
1 parent fe85a42 commit 3fff85f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ export class Store {
129129
this._setupModuleMutations(modules || this._modules)
130130
}
131131

132+
/**
133+
* Replace entire state tree.
134+
*/
135+
136+
___replaceState (newState) {
137+
const state = this._vm._data
138+
const clone = deepClone(newState)
139+
Object.keys(clone).forEach(key => {
140+
state[key] = clone[key]
141+
})
142+
}
143+
132144
/**
133145
* Attach sub state tree of each module to the root tree.
134146
*

0 commit comments

Comments
 (0)