This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-18
Channels
- # aleph (7)
- # announcements (11)
- # beginners (186)
- # calva (17)
- # cider (26)
- # clj-kondo (4)
- # cljdoc (12)
- # cljs-dev (3)
- # clojars (1)
- # clojure (105)
- # clojure-berlin (1)
- # clojure-chicago (1)
- # clojure-dev (34)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-nl (27)
- # clojure-russia (19)
- # clojure-uk (25)
- # clojuredesign-podcast (4)
- # clojurescript (54)
- # cursive (6)
- # data-science (1)
- # datascript (11)
- # datomic (5)
- # emacs (3)
- # events (2)
- # fulcro (13)
- # graalvm (5)
- # jobs (15)
- # leiningen (7)
- # luminus (3)
- # melbourne (1)
- # nrepl (1)
- # nyc (2)
- # onyx (4)
- # pathom (6)
- # pedestal (18)
- # re-frame (19)
- # reagent (10)
- # shadow-cljs (27)
- # spacemacs (32)
- # sql (11)
- # tools-deps (35)
- # vim (50)
Hi. I'm writing an app usign re-frame and I'm not sure where I should put parts of code. I created a button to load a file using File API. IIUC the button should send event to event handler. The handler should declare what should be done with it - in my case I want to load the file using File API in browser. So then I should create (reg-fx ...) which will actually load the file and then what? Store it directly in app-db? Can I dispatch on-load/on-error events from an effect handler?
For something like this I’ve typically created stateful components that work with the file api in reagent - then when the work was done (create / modify files) I dispatch an event to persist data etc..
Thanks. I'll look at that.
How can we make pessimistic updates in re-frame
?
Like change persists in local db after server request is successful.
Have you taken a look at something like https://github.com/Day8/re-frame-http-fx? The approach looks like: 1. Dispatch event that triggers request side-effect (no data changes and on-success & on-failure event handlers are defined) 2. On 2xx response update your db with the server response
I’ve also written a lib that adds a little more state tracking to requests https://github.com/oconn/re-frame-request that you may find interesting.
@U1APR44RE thanks. That helps.
you can put something in the db in the same effect handler, and take it out on success or failure
yeah that would work
@deadghost I think the re-frame
docs have an example like this as well
some mentions of it in https://github.com/Day8/re-frame/blob/master/docs/Talking-To-Servers.md