mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 08:26:51 +00:00
15 lines
341 B
TypeScript
15 lines
341 B
TypeScript
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
|
|
}
|
|
}
|