client.mjs
646 Bytes
import { configureStore } from '@reduxjs/toolkit'
import { setupListeners } from '@reduxjs/toolkit/query'
export function getBrowserStore() {
const {
astroStore: store
} = window
return store
}
export async function configureAstroStore(userStoreConfig) {
const {
__PRELOADED_STATE__: preloadedState,
} = window
console.log('preloadedState', preloadedState)
if (preloadedState) {
const store = configureStore({
...userStoreConfig,
preloadedState,
})
await setupListeners(store.dispatch)
//await resetApiState(store.dispatch)
console.log('store', store)
window.astroStore = store
}
}