mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 16:35:39 +00:00
Complete refactor (#123)
This commit is contained in:
14
src/app/state/LocalStorageProperty.ts
Normal file
14
src/app/state/LocalStorageProperty.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Property } from './Property'
|
||||
|
||||
export class LocalStorageProperty extends Property<string> {
|
||||
constructor(private id: string, fallback: string) {
|
||||
super(localStorage.getItem(id) ?? fallback)
|
||||
}
|
||||
set(value: string) {
|
||||
super.set(value)
|
||||
localStorage.setItem(this.id, value)
|
||||
}
|
||||
get(): string {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user