Fork me on GitHub

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


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


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


but maybe not, I was just playing with the thought


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


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


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


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


hello. Here in docs the creating of reagent components is discussed: 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?


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


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


@negaduck you know about re-frisk?


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


then i have misunderstood what you mean by 'trace'


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.


@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)

β”œβ”€β”€ 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


@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 ?


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


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


Wait on, here comes my tree.


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)


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


@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- 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.


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


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


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


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


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"


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


not sure why


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