# extendify/0.3.0/src/state/GlobalState.js

Extendify, version 0.3.0. 36 lines.

- Page: https://pluginprobe.com/plugins/extendify/0.3.0/code/src/state/GlobalState.js
- Raw: https://pluginprobe.com/plugins/extendify/0.3.0/raw/src/state/GlobalState.js
- Modified: 2022-01-25T20:17:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/0.3.0/code/src/state/GlobalState.js#L10-L20`.

```javascript
import create from 'zustand'
import { persist } from 'zustand/middleware'

export const useGlobalStore = create(
    persist(
        (set, get) => ({
            open: false,
            metaData: {},
            // These two are here just to persist their previous values,
            // but could be refactored to be the source instead.
            // It would require a refactor to state/Templates.js
            currentTaxonomies: {},
            currentType: 'pattern',
            modals: [],
            pushModal: (modal) => set({ modals: [modal, ...get().modals] }),
            popModal: () => set({ modals: get().modals.slice(1) }),
            removeAllModals: () => set({ modals: [] }),
            updateCurrentTaxonomies: (data) =>
                set({
                    currentTaxonomies: Object.assign({}, data),
                }),
            updateCurrentType: (data) => set({ currentType: data }),
            setOpen: (value) => {
                set({ open: value })
            },
        }),
        {
            name: 'extendify-global-state',
            partialize: (state) => {
                delete state.modals
                return state
            },
        },
    ),
)

```
