Fork me on GitHub
#re-frame
<
2020-08-17
>
Casey08:08:25

In my event-fx registration, is it possible to use subscriptions to query the db? I don't need the reactivity of subs, but I don't want to duplicate the code in the sub query handler.

Casey08:08:16

In particular the sub query I want to use itself is a layer 3 (materialised view) subscription, so I can't simply refactor out the body of the sub into a standalone function

sandbags12:08:24

For creating a "production" version of my re-frame app I'm not at all clear what to do. I couldn't see a section in the docs on this. Ideally I'd like it to be packed into the smallest possible vessel, maybe even using something like Electron. Am I missing some docs?

p-himik13:08:35

What you describe sounds completely orthogonal to re-frame. Re-frame is just a state management library, that's it.

sandbags13:08:09

Eh? You use re-frame to build an app. You might argue "Why are you asking this here?" there's nothing specific about packaging up a re-frame based application — which would be fair enough. But I don't think the question itself is unreasonable. I ask here because I'm building the app with re-frame and I assume others are likewise and might give me some pointers for how they've distributed the release versions of their app.

mikethompson13:08:08

@sandbags You may want to look at template like re-frame-template. It will create a scaffold re-frame application for you. That scaffold will supply dev and prod builds (read the docs provided).

sandbags13:08:36

Ah, @U051MTYAB thank you. In fact I am based on that template but I hadn't appreciated it handled a prod build. I will take another look, thanks.

mikethompson13:08:49

As @U2FRKM4TW pointed out, this is not really a re-frame issue. This is a build tool issue. Look towards shadow-cljs etc.

sandbags13:08:19

Yes my lack of any recent JS/CLJS/Reagent use/experience is catching me out here. I was just hoping to tap the wisdom of people building apps with re-frame.

p-himik13:08:20

Build tool, yes, but also packaging. And deployment, assuming we're talking about a web app (although you mentioned Electron above, which is for desktop apps).

sandbags13:08:06

This is an app built with re-frame but it's intended as a desktop app, hence why ultimately I might prefer to use something like Electron. But I haven't done this kind of stuff in ages (if at all) and am a bit at sea with all the options/frameworks/etc…

alpox15:08:34

Maybe looking at some template would help to get some ideas when talking specifically at electron https://github.com/chimez/shadow-electron-re-frame-starter

sandbags15:08:02

Thanks alpox. I saw that was wondering if it was still good after 2 years (so much moves so fast). I'll definitely give it a look now, thank you.

alpox15:08:24

I did not try it lately so chances are that things changed but I would guess not by much. It should still help to get an idea.

sandbags15:08:41

Is the use of 'electorn' rather than 'electron' whimsy/mispelling? Or is there something I should be aware of there do you think?

alpox15:08:07

Thats a simple miss-spell. You install electron globally under the name "electron" npm install electron -g which also provides you with the cli-tool named electron

sandbags15:08:30

Okay I figured as much but thought it wise to check. I've not really any knowledge of JS eco-system/Electron beyond the general.

alpox15:08:32

If you run into questions concerning the JS ecosystem you can write me a PM - I'm still doing more in the JS ecosystem than Clojure due to my job. (But with Electron I did only some hobby-testing)

sandbags15:08:45

Thanks alpox, that's very kind of you.

sandbags16:08:44

The re-frame-template says to use lein release for a production build. Is that https://github.com/technomancy/lein-release ? This appears to be 10yr old and superceded by https://github.com/technomancy/lein-tar but is, in any case, complaining about my lack of gpg and something about not being able to sign a tag. That seems to be lein vcs at work. Looking at the docs for that I've passed --no-sign as an argument which stopped it complaining about that but now it errors with "On branch master. nothing to commit, working tree clean. java.lang.Exception: Couldn't commit. git exit code: 1" but, when I tried it with something to commit it was complaining that my working tree wasn't clean! Neither lein release or lein tar seem to mention anything about git in their docs so I am wondering if I am looking at the wrong thing?

sandbags16:08:55

Ah, is lein release actually a kind of alias for lein shadow release?

superstructor22:08:36

Yep its an alias for lein shadow release. @sandbags

superstructor22:08:46

Prehaps unfortunate naming if it is going to cause confusion.

sandbags08:08:48

@U0G75S29H in this case somehow I was missing the :release alias in my project.clj and so something was happening but it's not clear what — in this case I think it was confusing

sandbags08:08:59

but it might be a very rare case

superstructor09:08:59

Thanks for the feedback @sandbags :thumbsup: I'll have to think about how to best mitigate it.

lilactown16:08:58

@sandbags I believe it means literally type lein release have you tried that?

sandbags16:08:11

Yes, that's the command I am running.

lilactown16:08:52

and what happens when you run lein release?

lilactown16:08:07

it was unclear from your message, since you started talking about some other things

sandbags16:08:36

If I don't use --no-sign I get errors about gpg being missing and not being able to sign a git tag.

lilactown16:08:52

it sounds like you’ve modified your project.clj to add the vcs plugin

sandbags16:08:10

Not as far as I know.

sandbags16:08:38

I've just searched my project.clj for any sign of it and I can't see it. I certainly didn't add it myself as this is the first I've heard of it.

lilactown16:08:45

I just did this:

$ lein new re-frame foo
$ cd foo
$ lein release
and it downloaded all of the needed dependencies, built the app successfully

p-himik16:08:06

Was about to write the same exact thing. :)

lilactown16:08:32

@sandbags could you paste your project.clj?

sandbags16:08:27

I'm running the same test as lilactown a second

lilactown16:08:28

after you’ve done that, I would ensure that you don’t have any lein profiles that are interfering. You can check that by looking in ~/.lein/profiles.clj

sandbags16:08:46

Okay your test works here also.

lilactown16:08:34

your :aliases is missing the release alias that is present in the template

lilactown16:08:57

:aliases {"dev"          ["do"
                            ["shell" "echo" "\"DEPRECATED: Please use lein watch instead.\""]
                            ["watch"]]
            "watch"        ["with-profile" "dev" "do"
                            ["shadow" "watch" "app" "browser-test" "karma-test"]]

            "prod"         ["do"
                            ["shell" "echo" "\"DEPRECATED: Please use lein release instead.\""]
                            ["release"]]

            "release"      ["with-profile" "prod" "do"
                            ["shadow" "release" "app"]]

            "build-report" ["with-profile" "prod" "do"
                            ["shadow" "run" "shadow.cljs.build-report" "app" "target/build-report.html"]
                            ["shell" "open" "target/build-report.html"]]

            "karma"        ["do"
                            ["shell" "echo" "\"DEPRECATED: Please use lein ci instead.\""]
                            ["ci"]]
            "ci"           ["with-profile" "prod" "do"
                            ["shadow" "compile" "karma-test"]
                            ["shell" "karma" "start" "--single-run" "--reporters" "junit,dots"]]}

sandbags16:08:13

Okay that's werid, I can't think of any reason why I would delete it. Most of the lein template is magic gibberish to me.

sandbags16:08:30

Thanks for catching that though. I would never have thought that could happen.

sandbags16:08:36

In fact I am missing also watch and ci

lilactown16:08:59

maybe you used an older version? who knows

sandbags16:08:18

Hard to say, but I think this project was only started about 3 weeks ago

sandbags16:08:50

That did the trick though, thanks lilactown. In absense of that definition who knows what it was running.