# extendify/0.10.1/src/Library/state/GlobalState.js

Extendify, version 0.10.1. 37 lines.

- Page: https://pluginprobe.com/plugins/extendify/0.10.1/code/src/Library/state/GlobalState.js
- Raw: https://pluginprobe.com/plugins/extendify/0.10.1/raw/src/Library/state/GlobalState.js
- Modified: 2022-07-19T16:46:12+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.10.1/code/src/Library/state/GlobalState.js#L10-L20`.

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

export const useGlobalStore = create(
    subscribeWithSelector(
        persist(
            (set, get) => ({
                open: false,
                ready: 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: { ...data } }),
                updateCurrentType: (data) => set({ currentType: data }),
                setOpen: (value) => set({ open: value }),
                setReady: (value) => set({ ready: value }),
            }),
            {
                name: 'extendify-global-state',
                partialize: (state) => {
                    delete state.modals
                    delete state.ready
                    return state
                },
            },
        ),
    ),
)

```
