fp-ts-local-storage
fp-ts-local-storage copied to clipboard
All local storage interactions are unsafe
Per here, local storage can throw for many reasons, for example - something a project of mine has been bitten by before - the user having disabled it in their browser.
With this in mind, all of the APIs in this library are currently deceptively unsafe. Some options:
- Add documentation alluding to this unsafety
- Add new safe variants, and prefix the preexisting ones with
unsafe
- Rewrite everything to be safe - presumably using
E.tryCatch
under the hood and asking for an error handler from the user - e.g.number -> IO<Option<string>>
becomes(unknown -> E) -> number -> IO<Either<E, Option<string>>>
I think that a solution could be use IOEither
and release a new major version of the library
Thanks @SamHH
Add documentation alluding to this unsafety
This is a good first step.