Fork me on GitHub
#re-frame
<
2016-04-27
>
aboekhoff06:04:44

Are there any popular libraries for forms and/or synchronization?

aboekhoff06:04:59

I suspect many people must be rolling their own input validation and remote synchronization code.

aboekhoff06:04:36

I suppose it could be tough to write something configurable enough to satisfy the use cases of a wide audience.

danielcompton07:04:07

Re-com, re-forms are two I know of

jvuillermet10:04:40

Hello, I had a "logged" middleware that was checking for a value in cookie so that was working fine but I now need to make an http call so now I'm dealing with async code and I have no idea how to keep this functionality as middleware

jvuillermet10:04:17

I'm coming back to a projet that was using reframe 0.3.0 so I may have missed some new features but the wiki didnt seem to change, at least for the talking to server and middleware sections

mikethompson10:04:10

The async code will itself dispatch the result, right?

mikethompson10:04:26

So there will be middleware on the disptched-to handler

jvuillermet10:04:35

(defn logged
  [handler]
  (fn logged-handler
    [db v]
    (if (is-logged?)
      (handler db v)
      db))

jvuillermet10:04:54

so the answer was no I guess

jvuillermet10:04:11

but now islogged would be async

jvuillermet10:04:20

Im a bit confused

jvuillermet11:04:10

Should I create an logged handler in opposition of a middleware that will take a follow-up action as param and decide to dispatch it or not

jvuillermet11:04:31

(dispatch [:logged :submit-form])

jvuillermet11:04:58

but I feel thats better as a middleware

rui.yang13:04:13

wonder if anyone using reframe as frontend, clojure as backend, and managed to use figwheel to do the frontend stuff?

rui.yang13:04:37

I am a bit confused. when using figwheel, js is served at 3449 port, normally backend will be at 8080 port. how does frontend fire ajax to backend? in prod, you could use relative url, but in dev, they are using different ports.

fasiha14:04:13

@rui.yang: I had the exact same problem a few weeks ago! Are you already using http-kit or jetty or any webserver for the backend, or were you like me and tried to go as long as possible using figwheel itself to run the backend 😛 ?

fasiha14:04:41

So my setup (I've been meaning to write this up but haven't yet, so this might be a bit rough): in project.clj defproject, I have :main app.handler, and in src/clj/app/handler.clj I have set up my Compojure app as well as http-kit startup.

fasiha14:04:11

So lein run will start the backend and start serving

fasiha14:04:06

I also have a Compojure route: (route/resources "/") so that http://localhost:3600/index.html (in your case, 8080 will be the port) will load index.html and pull down whatever cljs assets have been built by lein fighweel dev.

fasiha14:04:16

When you open that URL, the browser will try to connect to the figwheel websocket (http://localhost:3449) once a second, and will console.error if it can't reach it. If you run lein figwheel dev, that starts up figwheel's server, and your client connects to it and figwheel is running.

fasiha14:04:14

So I have two terminals, one running lein run and another running lein fighweel dev. (The third is a lein repl connected to the nrepl server running inside my app 😄)

fasiha14:04:02

This whole aspect of Clojure/Script was really confusing for me to figure out, and I'm sure the above was unclear so let me know where I can clarify. I would like to make a stand-alone repo showing how I at least do this… after my deadline next week

danielcompton18:04:57

Chestnut is a lein template that sets this up for you. It uses om, but you could pull that out.

rui.yang22:04:35

@fasiha: great tips, I have copied all your comments in case slack lose history. will have a play later if chestnut not working.

rui.yang23:04:32

@danielcompton: thanks for pointing me to chestnut. it is great that figwheel has :ring-handler option, but I am trying out https://github.com/pedestal/pedestal. any idea how to incorporate pedestal with figwheel?