Skip to content

Commit f820bfa

Browse files
committed
wip
1 parent 3be003c commit f820bfa

File tree

1 file changed

+9
-7
lines changed
  • packages/signals/signals/src/core/buffer

1 file changed

+9
-7
lines changed

packages/signals/signals/src/core/buffer/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ interface IDBPObjectStoreSignals
2525
'readonly' | 'readwrite' | 'versionchange'
2626
> {}
2727

28-
export class SignalStore implements SignalPersistentStorage {
28+
export class SignalStoreIndexDB implements SignalPersistentStorage {
2929
static readonly DB_NAME = 'Segment Signals Buffer'
3030
static readonly STORE_NAME = 'signals'
3131
private db: Promise<IDBPDatabaseSignals>
3232
private maxBufferSize: number
3333
private sessionKeyStorage = new WebStorage(window.sessionStorage)
3434
static deleteDatabase() {
35-
return indexedDB.deleteDatabase(SignalStore.DB_NAME)
35+
return indexedDB.deleteDatabase(SignalStoreIndexDB.DB_NAME)
3636
}
3737

3838
async getStore(
@@ -41,8 +41,8 @@ export class SignalStore implements SignalPersistentStorage {
4141
): Promise<IDBPObjectStoreSignals> {
4242
const db = database ?? (await this.db)
4343
const store = db
44-
.transaction(SignalStore.STORE_NAME, permission)
45-
.objectStore(SignalStore.STORE_NAME)
44+
.transaction(SignalStoreIndexDB.STORE_NAME, permission)
45+
.objectStore(SignalStoreIndexDB.STORE_NAME)
4646
return store
4747
}
4848

@@ -52,9 +52,11 @@ export class SignalStore implements SignalPersistentStorage {
5252
}
5353

5454
private async initSignalDB(): Promise<IDBPDatabaseSignals> {
55-
const db = await openDB<SignalDatabase>(SignalStore.DB_NAME, 1, {
55+
const db = await openDB<SignalDatabase>(SignalStoreIndexDB.DB_NAME, 1, {
5656
upgrade(db) {
57-
db.createObjectStore(SignalStore.STORE_NAME, { autoIncrement: true })
57+
db.createObjectStore(SignalStoreIndexDB.STORE_NAME, {
58+
autoIncrement: true,
59+
})
5860
},
5961
})
6062
logger.debug('Signals Buffer (indexDB) initialized')
@@ -171,6 +173,6 @@ export const getSignalBuffer = <
171173
>(
172174
settings: SignalBufferSettingsConfig<T>
173175
) => {
174-
const store = settings.signalStorage ?? new SignalStore(settings)
176+
const store = settings.signalStorage ?? new SignalStoreIndexDB(settings)
175177
return new SignalBuffer(store)
176178
}

0 commit comments

Comments
 (0)