This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-16
Channels
- # atom-editor (6)
- # babashka (31)
- # beginners (34)
- # calva (1)
- # cider (21)
- # clj-kondo (5)
- # cljsrn (2)
- # clojars (6)
- # clojure (35)
- # clojure-europe (3)
- # clojure-norway (2)
- # clojurescript (4)
- # conjure (10)
- # cursive (8)
- # data-science (78)
- # fulcro (23)
- # graphql (10)
- # helix (2)
- # luminus (1)
- # off-topic (50)
- # other-languages (1)
- # pathom (8)
- # re-frame (9)
- # reagent (9)
- # reitit (1)
- # rewrite-clj (6)
- # shadow-cljs (134)
- # tools-deps (53)
- # vscode (1)
- # xtdb (4)
@marcus.akre be careful with that approach. See the FAQ entry on Laggy Inputs
@mikethompson Ah thanks! Didn't know that would be a problem. One of the proposed solutions is to switch to use dispatch-sync. I guess that could work if it is not used too much.
All the examples and small projects I've seen tend to group events, subs, and fx in one file... or one file for events, one for subs, etc. How do real-world larger projects handle this? I can see on events ns getting really huge
Initially, I split into files that deal with a single "piece" of the app, however you define it. When one such file becomes unwieldy, I split it into smaller chunks. Usually a file per component. So I might start with something like main_page.cljs
and end up with something like login_form.cljs
, navbar.cljs
, items_table.cljs
, and so on.
Do you group -db , -event-fx, -fx and, -subs together by "piece"/ "action" or by type (e.g., all subs together, all fx together, etc)?
Nope, I don't see the point of grouping by these things. Otherwise, it would also make sense to group def
and defn
separately, and we don't do that.
Also, suppose you have a sub like :app/my-value
. And you have an event :app/set-my-value
. Why would you ever split them? Unless you want to have to change multiple sources if you ever decide to change how the value is actually stored.
I use a hybrid approach: separate, top-level namespaces for subs, events and db for things that are global/application-wide, and then individual namespaces for specific components, with db, subs, and event handlers as sections within the namespace.
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).