Skip to content

Commit

Permalink
don't pin serialized data while saving to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Oct 11, 2023
1 parent f4b375b commit 27ab521
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ namespace microcode {
}

public save(slot: string, progdef: ProgramDefn) {
const saved: SavedState = {
let saved: SavedState = {
progdef: progdef.toObj(),
version: microcode.VERSION,
}
const s = JSON.stringify(saved)
let s = JSON.stringify(saved)
saved = undefined
this.saveSource(slot, s)
}

public load(slot: string): ProgramDefn {
try {
const s = settings.readString(slot)
let s = settings.readString(slot)
if (s) {
const saved: SavedState = JSON.parse(s)
s = undefined
if (saved) return ProgramDefn.FromObj(saved.progdef)
}
} catch (e) {
Expand Down

0 comments on commit 27ab521

Please sign in to comment.