Richly-typed and versioned localStorage keys for Purescript
-
Register your localStorage key
pv <- Purversion.make { key: "a-localstorage-key" -- key name , encode: intToString -- data encoding. we're storing integers , decode: stringToInt , migrations: [Identity] -- data migrations, if applicable }
Note that the monad is just
Effect
, nothing special. -
Save and load values
-- Put a value into the key Purversion.save pv 100 -- Get a value out of the key value <- Purversion.load pv log $ show value -- 100
-
No step 3. That's it!
- See test/Example.purs or test/Main.purs for examples
- See Pursuit for hard documentation
Enjoy!