Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 3x 3x 3x 3x 3x 14x 26x 11x 7x 4x 26x | import { isBrowser } from '@wirewheel/cmp/src/utils/isBrowser'
import { CookiePersistentStore } from '@wirewheel/cmp/src/modules/CookiePersistentStore'
import { MemoryStore } from '@wirewheel/cmp/src/modules/MemoryStore'
import { PersistentStore } from '@wirewheel/cmp/src/modules/PersistentStore'
import { CookieConfig } from '@wirewheel/cmp/src/entities/CookieConfig'
export abstract class PersistentStoreFactory {
private static instance?: PersistentStore
static reset() {
PersistentStoreFactory.instance = undefined
}
static getStore(cookieConfig?: CookieConfig): PersistentStore {
if (!PersistentStoreFactory.instance || cookieConfig?.refreshOnVisit) {
if (isBrowser() && PersistentStore.canSetCookies()) {
PersistentStoreFactory.instance = new CookiePersistentStore({
cookieExpirationInDays: cookieConfig?.expirationInDays,
refreshOnVisit: cookieConfig?.refreshOnVisit,
})
} else {
PersistentStoreFactory.instance = new MemoryStore()
}
}
return PersistentStoreFactory.instance
}
}
|