Skip to content

Commit 8b01333

Browse files
committed
[persisters] Clear queue
1 parent 8262ffe commit 8b01333

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/common/array.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const arrayFilter = <Value>(
5656
cb: (value: Value) => boolean,
5757
): Value[] => array.filter(cb);
5858

59-
export const arrayClear = <Value>(array: Value[], to?: number): Value[] =>
59+
export const arrayClear = <Value>(array: Value[] = [], to?: number): Value[] =>
6060
array.splice(0, to);
6161

6262
export const arrayPush = <Value>(array: Value[], ...values: Value[]): number =>

src/persisters/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
PersisterStats,
1414
Persists as PersistsType,
1515
} from '../@types/persisters/index.d.ts';
16-
import {arrayPush, arrayShift} from '../common/array.ts';
16+
import {arrayClear, arrayPush, arrayShift} from '../common/array.ts';
1717
import {
1818
errorNew,
1919
ifNotUndefined,
@@ -257,7 +257,10 @@ export const createCustomPersister = <
257257

258258
const getStore = (): Store => store;
259259

260-
const destroy = (): Persister<Persist> => stopAutoLoad().stopAutoSave();
260+
const destroy = (): Persister<Persist> => {
261+
arrayClear(mapGet(scheduleActions, scheduleId));
262+
return stopAutoLoad().stopAutoSave();
263+
};
261264

262265
const getStats = (): PersisterStats => ({loads, saves});
263266

0 commit comments

Comments
 (0)