@isoftdata/svelte-store-crud
Advanced tools
@@ -42,2 +42,5 @@ import type { ConditionalKeys, Simplify } from 'type-fest'; | ||
| type EntityOrId<T, K extends EntityIdKey<T>> = T | T[K]; | ||
| export interface CrudRuneStoreOptions<T> { | ||
| onchange?: (entity: T, crudType: CrudType) => void; | ||
| } | ||
| export declare class CrudRuneStore<T, K extends EntityIdKey<T>> implements CrudStoreInterface<T, K> { | ||
@@ -51,3 +54,3 @@ #private; | ||
| deletedEntries: Array<[EntityIdValue<T>, T]>; | ||
| constructor(idKey: K); | ||
| constructor(idKey: K, options?: CrudRuneStoreOptions<T>); | ||
| set(value: CrudMap<T> | MapCrudMap<T> | ArrayCrudMap<T>): void; | ||
@@ -54,0 +57,0 @@ static getValuesForSet<T>(values: EntityMap<T> | Map<EntityIdValue<T>, T> | Array<T>): Array<T>; |
@@ -125,2 +125,3 @@ import { writable } from 'svelte/store'; | ||
| #idKey; | ||
| #onchange; | ||
| // These public properties automatically get getters created | ||
@@ -134,4 +135,5 @@ createdValues = $derived(Array.from(this.#created.values())); | ||
| #hasChanges = $derived(!!this.createdValues.length || !!this.updatedValues.length || !!this.deletedValues.length); | ||
| constructor(idKey) { | ||
| constructor(idKey, options) { | ||
| this.#idKey = idKey; | ||
| this.#onchange = options?.onchange; | ||
| } | ||
@@ -245,2 +247,3 @@ #updateEntity(entity, crudType) { | ||
| } | ||
| this.#onchange?.(entity, crudType); | ||
| } | ||
@@ -247,0 +250,0 @@ toJSON() { |
+1
-1
| { | ||
| "name": "@isoftdata/svelte-store-crud", | ||
| "version": "2.6.0", | ||
| "version": "2.7.0", | ||
| "files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
18792
1.34%335
1.82%