Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-redux
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
750c1a03
authored
2024-05-03 15:20:47 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Split index into astro+session.
1 parent
9aaa6cbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
21 deletions
package.json
src/index.mjs → src/astro.mjs
src/session.mjs
package.json
View file @
750c1a0
...
...
@@ -2,10 +2,11 @@
"name"
:
"astro-redux"
,
"type"
:
"module"
,
"exports"
:
{
".
"
:
"./src/index
.mjs"
,
".
/astro"
:
"./src/astro
.mjs"
,
"./client"
:
"./src/client.mjs"
,
"./slices"
:
"./src/slices.mjs"
,
"./react"
:
"./src/react.jsx"
,
"./session"
:
"./src/session.jsx"
,
"./ReduxIsland"
:
"./src/ReduxIsland.astro"
},
"sideEffects"
:
[
...
...
src/
index
.mjs
→
src/
astro
.mjs
View file @
750c1a0
import NodeCache from 'node-cache'
import { configureStore } from '@reduxjs/toolkit'
export const makeLeadingCase = (s) => s.substring(0, 1).toUpperCase() + s.substring(1)
export const fixUnsubscribe = async (store, action) => {
...
...
@@ -41,21 +38,4 @@ export const createAstroApiWrappers = (apiWrappers) => Object.entries(apiWrapper
return result
}, {})
export const sessionStoreCache = new NodeCache({
stdTTL: 600, // in seconds
useClones: false,
})
export const createGetSessionStore = (storeConfig) => (session) => {
const getStore = (sessionId) => {
const currentStore = sessionStoreCache.get(sessionId)
if (currentStore) return currentStore
const newStore = configureStore(storeConfig)
sessionStoreCache.set(sessionId, newStore)
return newStore
}
const { id: sessionId } = session
return getStore(sessionId)
}
export { default as AstroReduxProvider } from './Provider.astro'
...
...
src/session.mjs
0 → 100644
View file @
750c1a0
import NodeCache from 'node-cache'
import { configureStore } from '@reduxjs/toolkit'
export const sessionStoreCache = new NodeCache({
stdTTL: 600, // in seconds
useClones: false,
})
export const createGetSessionStore = (storeConfig) => (session) => {
const getStore = (sessionId) => {
const currentStore = sessionStoreCache.get(sessionId)
if (currentStore) return currentStore
const newStore = configureStore(storeConfig)
sessionStoreCache.set(sessionId, newStore)
return newStore
}
const { id: sessionId } = session
return getStore(sessionId)
}
Please
register
or
sign in
to post a comment