Fork me on GitHub
#re-frame
<
2017-02-14
>
borkdude10:02:44

Is re-frame also suited for usage server side? I noticed cljc is used a lot in the repo

borkdude10:02:01

@lsenta I hadn’t, but now I have.

borkdude10:02:47

I do think it could make sense to use it server side, the event system

borkdude10:02:36

but maybe not, I was just playing with the thought

lsenta10:02:07

It's natural to want to use the same tech on the full stack πŸ˜„

lsenta10:02:41

I think you can get away with just core.async if it's "just" server code. You don't need the whole subscription for rendering machinery

lsenta10:02:26

Someone shared a library that dispatch events between server and client code not so long ago, pipelines...something :thinking_face:

borkdude10:02:21

I would use it mainly for preventing callback hell, but that isn’t a problem on the JVM, but on NodeJS it could be useful

negaduck10:02:52

hello. Here in docs the creating of reagent components is discussed: https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#form-2--a-function-returning-a-function I have a question about form-2: why can’t we just do (let [some-setup …] (defn the-component […] …)) and use it directly instead of having a function that returns this thing?

negaduck10:02:53

on the second thought though, we would have to parameterize the setup, so never mind

negaduck11:02:29

how do you guys trace events flying around in your apps? I’ve just added the https://github.com/Day8/re-frame-tracer, it’s cool, but it requires to wrap large chunks of code. Any alternatives? I’m spoiled a bit by redux devtools extension.

sandbags12:02:17

@negaduck you know about re-frisk?

negaduck12:02:50

@sandbags, yes, but it doesn’t trace events as they go, as far as I can see

sandbags12:02:07

then i have misunderstood what you mean by 'trace'

scknkkrer17:02:00

Guys, I need some help. I started a project with re-frame but, I couldn’t configure my file structure, I guess… I created one file per a panel. ; Yes, I have panels. Can you show me an example for big re-frame application structure. Not from the documentation please.

zak17:02:19

@scknkkrer this is the tree from src for a re-frame project with a clj backend. Maybe not exactly "big" yet (one month into development)

src
β”œβ”€β”€ backend
β”‚Β Β  └── projectname
β”‚Β Β      β”œβ”€β”€ activity.clj
β”‚Β Β      β”œβ”€β”€ external_source.clj
β”‚Β Β      β”œβ”€β”€ issue.clj
β”‚Β Β      β”œβ”€β”€ protocols.clj
β”‚Β Β      β”œβ”€β”€ resource
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ activity.clj
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ frontend.clj
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ issue.clj
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ login.clj
β”‚Β Β      β”‚Β Β  └── misc.clj
β”‚Β Β      β”œβ”€β”€ routes.clj
β”‚Β Β      β”œβ”€β”€ scheduler.clj
β”‚Β Β      β”œβ”€β”€ server.clj
β”‚Β Β      β”œβ”€β”€ store.clj
β”‚Β Β      β”œβ”€β”€ system.clj
β”‚Β Β      └── util.clj
β”œβ”€β”€ common
β”‚Β Β  └── projectname
β”‚Β Β      β”œβ”€β”€ schema.cljc
β”‚Β Β      └── workflow.cljc
└── frontend
    └── projectname
        β”œβ”€β”€ cofx.cljs
        β”œβ”€β”€ core.cljs
        β”œβ”€β”€ data
        β”‚Β Β  └── persist.cljs
        β”œβ”€β”€ db.cljs
        β”œβ”€β”€ events.cljs
        β”œβ”€β”€ fx.cljs
        β”œβ”€β”€ interceptors.cljs
        β”œβ”€β”€ page
        β”‚Β Β  β”œβ”€β”€ issue.clj
        β”‚Β Β  β”œβ”€β”€ issue.cljs
        β”‚Β Β  β”œβ”€β”€ summary.clj
        β”‚Β Β  └── summary.cljs
        β”œβ”€β”€ routes.cljs
        β”œβ”€β”€ style.clj
        β”œβ”€β”€ subs.cljs
        β”œβ”€β”€ util.cljs
        └── views.cljs

scknkkrer17:02:38

@zak, It’s big for me. But, how could you configure this structure. Can you write about it ? One db initializer or per panels/pages. One event file or per panels/pages ?

scknkkrer17:02:14

I think, I did something wrong. All wrong. πŸ˜„ Because your structure is really organized.

zak17:02:03

This was based on the re-frame lein template. Mostly just renamed clj to backend and cljs to frontend

scknkkrer17:02:34

Wait on, here comes my tree.

zak17:02:06

To answer your question, the core namespace calls (reagent/render) with a root passed in from the views namespace and dispatches one :initialize-db using (re-frame/dispatch-sync)

zak17:02:21

I've only got one app-db for the UI

nrako17:02:20

@scknkkrer Another option you might consider would be to treat your panel(s) as a directory / module which is self-contained. You might find some helpful info here- https://github.com/Day8/re-frame/wiki/A-Larger-App#larger-apps. I came back to a project after some time, and I found it quite helpful to have the modules in their own ns. i.e. auth, users, etc.

shader20:02:42

what's the re-frame way to have a button trigger a file download?

shader20:02:01

currently my code is calling (set! js/location ...) to a url with the file

qqq20:02:07

isn't Itrigger a fie download" just "link to something the browser downloads" ?

shader20:02:50

hmm. I guess I might be able to generate a link with the appropriate url.

qqq20:02:17

unless there's some HTML5 tag of some sort, my understanding was: for download links: the server provides a mime-type, the browser decides "oh, this is a zip file, not a html/css/png; I should download it"

shader20:02:11

yeah; basically I just have a link, but for some reason it was implemented in javascript

shader20:02:25

not sure why

hkjels21:02:15

@shader: you might want to consider using open instead of location so you can make the target _blank