@@ -25,8 +25,10 @@ interface IDBPObjectStoreSignals
25
25
'readonly' | 'readwrite' | 'versionchange'
26
26
> { }
27
27
28
+ const MAX_BUFFER_SIZE_DEFAULT = 50
29
+
28
30
interface StoreSettings {
29
- maxBufferSize : number
31
+ maxBufferSize ? : number
30
32
}
31
33
export class SignalStoreIndexDB implements SignalPersistentStorage {
32
34
static readonly DB_NAME = 'Segment Signals Buffer'
@@ -50,7 +52,7 @@ export class SignalStoreIndexDB implements SignalPersistentStorage {
50
52
}
51
53
52
54
constructor ( settings : StoreSettings ) {
53
- this . maxBufferSize = settings . maxBufferSize
55
+ this . maxBufferSize = settings . maxBufferSize ?? MAX_BUFFER_SIZE_DEFAULT
54
56
this . db = this . initSignalDB ( )
55
57
}
56
58
@@ -137,7 +139,7 @@ export class SignalStoreSessionStorage implements SignalPersistentStorage {
137
139
private maxBufferSize : number
138
140
139
141
constructor ( settings : StoreSettings ) {
140
- this . maxBufferSize = settings . maxBufferSize
142
+ this . maxBufferSize = settings . maxBufferSize ?? MAX_BUFFER_SIZE_DEFAULT
141
143
}
142
144
143
145
add ( signal : Signal ) : void {
@@ -216,13 +218,9 @@ export const getSignalBuffer = <
216
218
> (
217
219
settings : SignalBufferSettingsConfig < T >
218
220
) => {
219
- const settingsWithDefaults : StoreSettings = {
220
- maxBufferSize : 50 ,
221
- ...settings ,
222
- }
223
221
const store =
224
222
settings . signalStorage ?? settings . storageType === 'session'
225
- ? new SignalStoreSessionStorage ( settingsWithDefaults )
226
- : new SignalStoreIndexDB ( settingsWithDefaults )
223
+ ? new SignalStoreSessionStorage ( settings )
224
+ : new SignalStoreIndexDB ( settings )
227
225
return new SignalBuffer ( store )
228
226
}
0 commit comments