|
@@ -114,6 +114,17 @@ const Spruce = {
|
|
|
},
|
|
|
|
|
|
reset(name, state) {
|
|
|
+ // This line is needed to ensure any watchers on
|
|
|
+ // the store itself are run when reset.
|
|
|
+ this.runWatchers(this.stores[name], '__self', state)
|
|
|
+
|
|
|
+ // This conditional will take any existing watchers on
|
|
|
+ // the store being reset and apply them back to the new
|
|
|
+ // state (see issue #105).
|
|
|
+ if (! state['__watchers']) {
|
|
|
+ state['__watchers'] = this.stores[name].__watchers
|
|
|
+ }
|
|
|
+
|
|
|
this.stores[name] = state
|
|
|
},
|
|
|
|
|
@@ -231,7 +242,7 @@ const Spruce = {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (target.__watchers.has(key)) {
|
|
|
+ if (target.__watchers.has(key) && key !== '__self') {
|
|
|
target.__watchers.get(key).forEach(f => f(value))
|
|
|
}
|
|
|
|