Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Oct 3, 2019
commit f39fc54ef43a25d3f83a93eca7ffe90cf614d5fb
8 changes: 2 additions & 6 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
export function loadState<T>(app, key): T {
const elem = <HTMLInputElement>document.querySelector(`#initial-state-${app}-${key}`)
if (elem === null) {
const msg = `Could not find initial state ${key} of ${app}`
console.error(msg)
throw new Error(msg)
throw new Error(`Could not find initial state ${key} of ${app}`)
}

try {
return JSON.parse(atob(elem.value))
} catch (e) {
const msg = `Could not parse initial state ${key} of ${app}`
console.error(msg)
throw new Error(msg)
throw new Error(`Could not parse initial state ${key} of ${app}`)
}
}
Loading