Fork me on GitHub

@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.


Oh, right - I use top-level nss as well for some things.


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).