Adding on, I take the same approach as manutter51. Sometimes I will even create a some-page directory that splits the subs, events, views, etc. into separate files if the page has a lot going on... like a dashboard with lots of widgets. But generally, a certain “fragment” of the application in my experience can contain everything (and probably should).
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.
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
https://github.com/day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md The initial discussion: https://github.com/day8/re-frame/issues/255
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?
What you describe sounds completely orthogonal to re-frame. Re-frame is just a state management library, that's it.
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.
@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).
Ah, @mikethompson 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.
As @p-himik pointed out, this is not really a re-frame issue. This is a build tool issue. Look towards shadow-cljs etc.
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.
👍
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).
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…
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
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.
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.
Is the use of 'electorn' rather than 'electron' whimsy/mispelling? Or is there something I should be aware of there do you think?
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
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.
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)
Thanks alpox, that's very kind of you.
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?
@superstructor 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
but it might be a very rare case
Thanks for the feedback @sandbags :thumbsup: I'll have to think about how to best mitigate it.
Ah, is lein release
actually a kind of alias for lein shadow release
?
@sandbags I believe it means literally type lein release
have you tried that?
Yes, that's the command I am running.
and what happens when you run lein release
?
it was unclear from your message, since you started talking about some other things
If I don't use --no-sign
I get errors about gpg being missing and not being able to sign a git tag.
it sounds like you’ve modified your project.clj
to add the vcs plugin
Not as far as I know.
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.
I just did this:
$ lein new re-frame foo
$ cd foo
$ lein release
and it downloaded all of the needed dependencies, built the app successfullyWas about to write the same exact thing. :)
@sandbags could you paste your project.clj?
I'm running the same test as lilactown a second
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
Okay your test works here also.
your :aliases
is missing the release
alias that is present in the template
: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"]]}
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.
Thanks for catching that though. I would never have thought that could happen.
In fact I am missing also watch and ci
maybe you used an older version? who knows
Hard to say, but I think this project was only started about 3 weeks ago
That did the trick though, thanks lilactown. In absense of that definition who knows what it was running.
Yep its an alias for lein shadow release. @sandbags
Prehaps unfortunate naming if it is going to cause confusion.