export const useLocationStore = defineStore('location', () => {
const defineState = () => ({
id: 1,
backgroundImage: '',
})
const state = defineState();
Object.keys(state).forEach((key) => {
state[key] = ref(state[key]);
});
function $reset() {
const originalState = defineState();
Object.keys(originalState).forEach((key) => {
state[key].value = originalState[key];
});
}
return {
...state
}
});
Last active
March 21, 2022 19:48
-
-
Save mgussekloo/25e287eed70babc5b5a91ee8ab88a559 to your computer and use it in GitHub Desktop.
Getting $reset in Pinia composition api
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment