Fork me on GitHub
#re-frame
<
2017-08-10
>
josh_horwitz01:08:09

Are there any tutorials / walkthroughs for re-frame that are recommended?

josh_horwitz01:08:50

Thanks @ericnormand , I was actually looking at your courses for your birthday sale but forget to go back and check!

ericnormand01:08:29

the re-frame components course goes on sale on monday

mikethompson06:08:15

@josh_horwitz there is always /docs in the repo?

sandbags10:08:09

Is there a better channel for CLJS-AJAX type issues than #clojurescript ?

sandbags10:08:54

if anyone knows why a GET from a file:/// based app for a relative file might fail with {:uri "index.edn", :last-method "GET", :last-error "", :last-error-code 0, :debug-message "No Error", :status 0, :status-text "Request failed.", :failure :failed} i'd be all ears

sandbags10:08:15

not the most useful error

sandbags10:08:29

ah, shit... of course... no server ... <insert more coffee>

sandbags10:08:13

hrmm... that's irritating... i need to use an AJAX get in development with Figwheel, but in deployment I'm looking at a relative file

oskarth10:08:06

I was tired of not finding the relevant re-frame docs (they are everywhere), so I made a dirty one md file with all the official docs concatenated, great for ctrl-f for specific keyword. There's no structure or anything, and it should probably be in the official repo in some capacity, but maybe someone else has the same problem: https://github.com/oskarth/re-frame-docs/blob/master/re-frame-one-doc.md

danielneal11:08:32

that's actually really useful

sandbags12:08:22

buggeryflip... it looks like you can't make an AJAX request from a file to another file... that probably makes sense from a security perspective (even if i might assume that allowing access to the same folder could make sense, but still) so i need to populate my DB at compile time

sandbags12:08:16

i'm sure that's possible, but i'm not sure how to do it, anyone know or seen an example?

manutter5112:08:42

@sandbags I’ve seen some online tutorials about client-side dev that just do npm install -g http-server, and then use http-server to serve their client files. Assumes you have nodejs installed, of course, but looks fairly painless otherwise

sandbags12:08:57

@manutter51 it's a nice idea thanks but doesn't work in my context

sandbags12:08:10

i guess if nothing else i can script something to compile my data into a .cljs file that gets included in the project

sandbags13:08:00

hrmm... i wonder if a macro is the answer

danielneal13:08:57

I think the build step would be less suprising...

danielneal13:08:36

If you use boot, you could maybe perhaps even use your existing clojure code to populate an edn file with the data in

sandbags14:08:26

I don't think I could load the EDN file though (since that's what I was trying to do in the first place)

sandbags14:08:01

In fact I've knocked up a quick ruby script to turn the data files into a CLJS file I can include in the project, it's imperfect, it means remembering to re-run it and rebuilding it when the data changes

frederic16:08:14

Hi, I’m considering doing something like this to keep my server updated about interesting changes in my app-db

(add-watch (re-frame/subscribe :cart) :notify-server-of-cart-change
	(fn [_ _ new-cart _]
		(notify-server! :cart-change new-cart)))

frederic16:08:34

if more experienced re-framers have an opinion for or against that technique, I’d love to hear it

tessellator19:08:06

@madstap A few weeks ago, you asked whether anyone was building re-frame apps using the finite-state machine approach described in a recent Cognitect blog post. My employer just green-lighted releasing our re-frame library for building apps in a similar way. You can check it out at https://github.com/Guaranteed-Rate/re-flow

madstap19:08:03

@tessellator Nice! Gonna check that out tonight. Thanks for remembering

tessellator19:08:35

Thanks for your patience! I'd certainly be interested in your thoughts. 🙂

madstap19:08:06

@sandbags To just read a edn file you could write a macro. Not sure about making figwheel pick up on changes to it, though.

;; util.clj
(defmacro compile-time-slurp [path]
  (slurp path))

;; db.cljs
(def db (edn/read-string (compile-time-slurp "foo.edn")))

jfntn19:08:08

Been very interested in that approach, will check it out for sure

yedi20:08:51

in re-frame form-2 components, should I keep my subscriptions in the outer fn or the inner fn?

yedi20:08:09

(they'll obviously get derefed in the inner fn)

pesterhazy20:08:21

either way is fine these days AFAIK

facundo22:08:45

does form fields validation belong in events or in views? I’m guessing events, but want some confirmation