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