This repository was archived by the owner on Oct 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,9 @@ export class Group<
315315 * @public
316316 * @param config - Configuration object
317317 */
318- public persist ( config : GroupPersistConfigInterface = { } ) : this {
318+ public persist (
319+ config : GroupPersistConfigInterface < Array < ItemKey > > = { }
320+ ) : this {
319321 config = defineConfig ( config , {
320322 key : this . _key ,
321323 followCollectionPersistKeyPattern : true ,
@@ -480,8 +482,8 @@ export interface GroupConfigInterface {
480482 isPlaceholder ?: boolean ;
481483}
482484
483- export interface GroupPersistConfigInterface
484- extends CreateStatePersistentConfigInterface {
485+ export interface GroupPersistConfigInterface < ValueType = any >
486+ extends CreateStatePersistentConfigInterface < ValueType > {
485487 /**
486488 * Whether to format the specified Storage key following the Collection Group Storage key pattern.
487489 * `_${collectionKey}_group_${groupKey}`
Original file line number Diff line number Diff line change 77} from '../state' ;
88import { Collection , DefaultItem } from './collection' ;
99import { SelectorKey } from './selector' ;
10- import { PersistentKey } from '../storages' ;
1110import { CollectionPersistent } from './collection.persistent' ;
1211
1312export class Item <
@@ -96,7 +95,7 @@ export class Item<
9695 * @public
9796 * @param config - Configuration object
9897 */
99- public persist ( config : ItemPersistConfigInterface = { } ) : this {
98+ public persist ( config : ItemPersistConfigInterface < DataType > = { } ) : this {
10099 config = defineConfig ( config , {
101100 key : this . _key ,
102101 followCollectionPersistKeyPattern : true ,
@@ -142,8 +141,8 @@ export interface ItemConfigInterface {
142141 isPlaceholder ?: boolean ;
143142}
144143
145- export interface ItemPersistConfigInterface
146- extends CreateStatePersistentConfigInterface {
144+ export interface ItemPersistConfigInterface < DataType = any >
145+ extends CreateStatePersistentConfigInterface < DataType > {
147146 /**
148147 * Whether to format the specified Storage key following the Collection Item Storage key pattern.
149148 * `_${collectionKey}_item_${itemKey}`
Original file line number Diff line number Diff line change @@ -424,7 +424,9 @@ export class EnhancedState<ValueType = any> extends State<ValueType> {
424424 * @public
425425 * @param config - Configuration object
426426 */
427- public persist ( config : CreateStatePersistentConfigInterface = { } ) : this {
427+ public persist (
428+ config : CreateStatePersistentConfigInterface < ValueType > = { }
429+ ) : this {
428430 config = defineConfig ( config , {
429431 key : this . _key ,
430432 } ) ;
Original file line number Diff line number Diff line change 1- import { defineConfig } from '@agile-ts/utils' ;
1+ import { copy , defineConfig } from '@agile-ts/utils' ;
22import {
33 CreatePersistentConfigInterface ,
44 getSharedStorageManager ,
@@ -27,7 +27,7 @@ export class StatePersistent<ValueType = any> extends Persistent {
2727 */
2828 constructor (
2929 state : EnhancedState < ValueType > ,
30- config : CreateStatePersistentConfigInterface = { }
30+ config : CreateStatePersistentConfigInterface < ValueType > = { }
3131 ) {
3232 super ( state . agileInstance ( ) , {
3333 loadValue : false ,
@@ -203,7 +203,7 @@ export class StatePersistent<ValueType = any> extends Persistent {
203203 getSharedStorageManager ( ) ?. set (
204204 storageItemKey ,
205205 this . onSave != null
206- ? this . onSave ( this . state ( ) . getPersistableValue ( ) )
206+ ? this . onSave ( copy ( this . state ( ) . getPersistableValue ( ) ) )
207207 : this . state ( ) . getPersistableValue ( ) ,
208208 this . storageKeys
209209 ) ;
You can’t perform that action at this time.
0 commit comments