Skip to content

Commit

Permalink
fix(store): fixed lost reactivity in core components store
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Jun 9, 2021
1 parent 39a0cbf commit 2af3355
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions src/core/modules/component/component-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Component {
aurora: app.theme === 'aurora',
},
style: component.style,
__storeCallbacks: [],
__updateQueue: [],
__eventHandlers: [],
__onceEventHandlers: [],
Expand Down Expand Up @@ -120,19 +119,19 @@ class Component {
}

getComponentStore() {
const { state, getters, dispatch } = this.f7.store;
const { state, _gettersPlain, dispatch } = this.f7.store;
const $store = {
state,
dispatch,
};
$store.getters = new Proxy(getters, {
$store.getters = new Proxy(_gettersPlain, {
get: (target, prop) => {
const obj = target[prop];
const callback = () => {
const callback = (v) => {
obj.value = v;
this.update();
};
obj.onUpdated(callback);
this.__storeCallbacks.push(callback, obj.__callback);
return obj;
},
});
Expand Down Expand Up @@ -298,10 +297,6 @@ class Component {
}
// Clear update queue
window.cancelAnimationFrame(this.__requestAnimationFrameId);
this.__storeCallbacks.forEach((callback) => {
this.f7.store.__removeCallback(callback);
});
this.__storeCallbacks = [];
this.__updateQueue = [];
this.__eventHandlers = [];
this.__onceEventHandlers = [];
Expand Down
4 changes: 2 additions & 2 deletions src/core/modules/store/create-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function createStore(storeParams = {}) {
removeGetterCallback(callback);
};

const getterValue = (getterKey, addCallback = false) => {
const getterValue = (getterKey, addCallback = true) => {
if (getterKey === 'constructor') return undefined;
propsQueue = [];
const value = getGetterValue(getterKey);
Expand Down Expand Up @@ -110,7 +110,7 @@ function createStore(storeParams = {}) {
if (!target[prop]) {
return undefined;
}
return getterValue(prop);
return getterValue(prop, true);
},
});

Expand Down

0 comments on commit 2af3355

Please sign in to comment.