reagent icon indicating copy to clipboard operation
reagent copied to clipboard

No documentation on how to structure a clojurescript / reagent project

Open stiofand opened this issue 6 years ago • 4 comments

No matter where an example clojurescript example / tutorial / rocket science explanation is, the second most glaringly obvious absence after a simple explanation of setup, is eplaining how on earth one is supposed to structure a project.

Every example shows how to create a component, combine components etc, but everything is in the same file and the same namspace!

If we are to believe this is a strong alternative use than javaScript for React projects then surely it would be conducive to actually show how to separate our files into their representative components / pages / helper folders for example, and not be led to believe its all one big file!

If I have a component I wish to include in a folder called "components" and I have an app page in a folder called pages for example, how does this relationship work in clojurescript.

Yes I am sure its a simple and easy implementation, but it has yet to grace any cohesive (and up to date) tutorial.

Any guidance would be much appreciated!

stiofand avatar Sep 05 '19 09:09 stiofand

E.g. Learn Reagent and Re-frame courses provide some examples on structuring projects:

https://www.jacekschae.com/learn-re-frame-free?coupon=REAGENT

The example app repos are public:

https://github.com/jacekschae/learn-re-frame-course-files/tree/master/increments/complete/src/app https://github.com/jacekschae/learn-reagent-course-files/tree/master/increments/complete/src/giggin

Re-frame template also generates project with several namespaces: https://github.com/Day8/re-frame-template

There are lots of different opinions on structuring projects and Reagent doesn't have one recommendation.

Deraen avatar Sep 05 '19 10:09 Deraen

This is certainly appreciated but doesn't really address the fundamental issue I pointed to. However In principle why should I refer away from reagent to another subscription service and another library / course to simply to learn a basic inherent part of a language?

Simply pointing to more boilerplate code does not clarify anything itself, it is not an "example" per se, just more analytical material to sift through.

This seems a little overblown to me. My comment was on the documentation here, and a simple section on how things are generally abstracted.

Leiningen template for reagent web app based on the re-frame pattern. Includes shadow-cljs and optionally cider, compjure, garden, less, re-com, re-frisk, re-frame-10x and secretary.

Ys it all sounds nice, but to my simple brain only obfuscates the issue even more.

stiofand avatar Sep 05 '19 10:09 stiofand

@Deraen saying that, I don't wish to sound ungrateful, in fact the tutorial is turning out to be very good in its own right. Certainly it's an additional step to get to where I was looking, but, I now know some more facile methods of creating reagent apps. So thank you for that.

stiofand avatar Sep 05 '19 13:09 stiofand

I don't think the Reagent library should prescribe how to structure your project. That's going to depend on your own taste and can vary depending on project. If you ask 10 developers how you should lay out your code in a project, you'll get at least 11 answers.

If you're asking about the mechanical aspect of "how do I include code from another namespace," then the ClojureScript docs have a fairly good reference for how namespaces work: https://clojurescript.org/guides/ns-forms

lilactown avatar Nov 04 '19 22:11 lilactown