This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-14
Channels
- # announcements (2)
- # aws (1)
- # babashka (18)
- # babashka-sci-dev (103)
- # beginners (165)
- # calva (51)
- # cider (8)
- # circleci (1)
- # clj-kondo (22)
- # clj-on-windows (2)
- # cljdoc (1)
- # cljfx (31)
- # cljs-dev (16)
- # clojure (81)
- # clojure-europe (71)
- # clojure-nl (7)
- # clojure-uk (11)
- # clojurescript (20)
- # code-reviews (26)
- # conjure (1)
- # contributions-welcome (1)
- # core-async (15)
- # cursive (8)
- # datomic (8)
- # defnpodcast (2)
- # eastwood (24)
- # emacs (10)
- # events (1)
- # fulcro (4)
- # funcool (31)
- # graalvm (43)
- # graphql (8)
- # honeysql (9)
- # introduce-yourself (1)
- # jobs (12)
- # kaocha (3)
- # lsp (28)
- # malli (4)
- # meander (4)
- # membrane (7)
- # off-topic (64)
- # other-languages (3)
- # pedestal (1)
- # polylith (31)
- # portal (5)
- # re-frame (4)
- # reitit (1)
- # releases (5)
- # rum (2)
- # schema (2)
- # sci (34)
- # shadow-cljs (21)
- # vscode (1)
Hi I'm struggling with persisting state in localstorage but I'm not even sure I should be trying to do this. To be clear - I can read and write to localstorage no problem. What I want is to have some control over the behaviour of the app if the page is refreshed or a copy opened in a new tab / window In previous React apps I've used redux-persist to keep a local copy of state, which makes this relatively seamless Redux-persist also allowed me to have white-lists and black-lists so I could control what was actually added to localstorage .. I've looked at browser-edn-store but that wants me to save using specific keys (which may be the way to go) .. other threads suggest transit-clj->str but even with a very modest/small state I'm getting write errors (even with {metadata? false} ) Any steers or thoughts would be most welcome - thanks
The state should be serializable. That's how it gets from the app into Fulcro Inspect - see https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/inspect/transit.cljs
Personally, I'd go with com.fulcrologic.fulcro.offline.browser-edn-store because I trust Tony :)
Short answer is I basically got this working I think my initial problems were related to not fully understanding the code / examples In essence I think transit-clj->str was being called twice, once manually by me and then inside browser-edn-store so by removing my manual step it seems to work Thanks again for your input as it certainly helped me to look at the problem in a different way and finally figure it out