Skip to content

Commit aa437e5

Browse files
authored
Merge pull request #152 from SolidOS/newFace-1
update
2 parents 3343cc7 + aa7c1ee commit aa437e5

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default [
66
{
77
ignores: [
88
'dist/**',
9+
'lib/**',
910
'node_modules/**',
1011
'coverage/**'
1112
],

package-lock.json

Lines changed: 32 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/logic/solidLogicSingleton.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as debug from '../util/debug'
22
import { authSession } from '../authSession/authSession'
33
import { createSolidLogic } from './solidLogic'
4+
import { SolidLogic } from '../types'
45

56
const _fetch = async (url, requestInit) => {
67
const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'
@@ -14,17 +15,23 @@ const _fetch = async (url, requestInit) => {
1415

1516
// Global singleton pattern to ensure unique store across library versions
1617
const SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')
17-
const globalThis = (typeof window !== 'undefined' ? window : global) as any
1818

19-
function getOrCreateSingleton() {
19+
// Type the global object properly with the singleton
20+
interface GlobalWithSingleton {
21+
[SINGLETON_SYMBOL]?: SolidLogic
22+
}
23+
24+
const globalThis = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton
25+
26+
function getOrCreateSingleton(): SolidLogic {
2027
if (!globalThis[SINGLETON_SYMBOL]) {
2128
debug.log('SolidLogic: Creating new global singleton instance.')
2229
globalThis[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)
2330
debug.log('Unique quadstore initialized.')
2431
} else {
2532
debug.log('SolidLogic: Using existing global singleton instance.')
2633
}
27-
return globalThis[SINGLETON_SYMBOL]
34+
return globalThis[SINGLETON_SYMBOL]!
2835
}
2936
//this const makes solidLogicSingleton global accessible in mashlib
3037
const solidLogicSingleton = getOrCreateSingleton()

0 commit comments

Comments
 (0)