You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing a Chrome extension using Pinia for state management and have encountered a specific issue with getters in the background script. Getters that directly return values work as expected. However, getters designed to return a function, which then accesses part of the state, do not work correctly. Instead of returning the expected value, they return the function definition itself.
For example, this getter works fine:
getter1(state) {
return state.someValue;
}
But this one does not, and just returns the function definition:
In the above case, getter2 when called like store.getter2('key1') in the background script returns the function (key) => state.someValue[key] itself rather than evaluating it.
Could this be a serialization issue with how functions are handled in Chrome's background script environment, or is there a better pattern I should be using for such dynamic getters in Pinia within a Chrome extension background script?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm developing a Chrome extension using Pinia for state management and have encountered a specific issue with getters in the background script. Getters that directly return values work as expected. However, getters designed to return a function, which then accesses part of the state, do not work correctly. Instead of returning the expected value, they return the function definition itself.
For example, this getter works fine:
But this one does not, and just returns the function definition:
In the above case, getter2 when called like store.getter2('key1') in the background script returns the function (key) => state.someValue[key] itself rather than evaluating it.
Could this be a serialization issue with how functions are handled in Chrome's background script environment, or is there a better pattern I should be using for such dynamic getters in Pinia within a Chrome extension background script?
Beta Was this translation helpful? Give feedback.
All reactions