import { PartialEntityCollection } from "../../models" ; import { ConfigurationPersistence } from "../../models/config_persistence" ; param path function stripCollectionPath ( path ) { return path . split ( "/" ) . filter ( ( e , i ) => i % 2 === 0 ) . reduce ( ( a , b ) => `${ a }/${ b }` ) ; } export function useBuildStorageConfigurationPersistence ( ) { function saveStorageCollectionConfig < M > ( path , data ) { const storageKey = `collection_config_${ stripCollectionPath ( path ) }` ; localStorage . setItem ( storageKey , JSON . stringify ( data ) ) ; } function getStorageCollectionConfig < M > ( path ) { const storageKey = `collection_config_${ stripCollectionPath ( path ) }` ; const item = localStorage . getItem ( storageKey ) ; return item ? JSON . parse ( item ) : { } ; } return { onCollectionModified : saveStorageCollectionConfig , getCollectionConfig : getStorageCollectionConfig } ; }