export const createStore = (initialState: StateType) => { let state: StateType = initialState const listeners = new Set<() => void>() return { getState: () => state, subscribe: (listener) => { listeners.add(listener) return () => {listeners.delete(listener)} }, setState: (newState) => { state = newState listeners.forEach((listener) => listener()) }, } }