mirror of
https://github.com/janishutz/fundamentals-of-webengineering.git
synced 2025-11-25 05:44:24 +00:00
Task 80% complete
This commit is contained in:
24
task_2_ts/ts/persistance.ts
Normal file
24
task_2_ts/ts/persistance.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
PersistanceConfig
|
||||
} from './types';
|
||||
|
||||
// Using localStorage for persistance
|
||||
const persistanceStore: PersistanceConfig = JSON.parse( localStorage.getItem( 'persistance' ) ?? '{}' );
|
||||
|
||||
export const store = (
|
||||
filename: string,
|
||||
size: number,
|
||||
sorted: string,
|
||||
active: string
|
||||
) => {
|
||||
persistanceStore[ `${ filename }-${ size }` ] = {
|
||||
'active': active,
|
||||
'sorted': sorted
|
||||
};
|
||||
localStorage.setItem( 'persistance', JSON.stringify( persistanceStore ) );
|
||||
};
|
||||
|
||||
|
||||
export const get = ( filename: string, size: number ) => {
|
||||
return persistanceStore[ `${ filename }-${ size }` ];
|
||||
};
|
||||
Reference in New Issue
Block a user