Created
May 12, 2024 01:16
-
-
Save vikramsoni2/6cddcf99587d538182c3e13c21848f7b to your computer and use it in GitHub Desktop.
Revisions
-
vikramsoni2 created this gist
May 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import { defineStore } from 'pinia'; export const useUppyStore = defineStore({ id: 'uppyStore', state: () => ({ state: {} }), actions: { getState() { return this.state; }, setState(patch) { const prevState = this.state; const nextState = { ...prevState, ...patch }; this.state = nextState; this.$patch({ state: nextState }); }, subscribe(listener) { const unsubscribe = this.$subscribe((mutation, state) => { const patch = mutation.payload; listener(mutation.oldState, state, patch); }, { immediate: true }); return unsubscribe; } } });