I'm trying to use [this example](https://github.com/metosin/reitit/blob/master/examples/frontend/src/frontend/core.cljs) for building a simple router with reitit, however I'm running into cyclical dependency issues. The issue comes from the router importing views, a link component requiring the router, and then my views requiring the links. Any advice on how to do the links or further reading would be much appreciated!
IMHO most router libs are complete overkill for what you actually need in the frontend. I always just have one function that takes the URI string and turns it into a datastructure of some kind. that data I put into the "app-db" (using re-frame terms) and render based on that using a simple case (or equivalent)
so that can look something like this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/db/generic.cljs#L22-L100. notice the ::m/current-page value being set
that is then loaded and used like this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#L140-L159
granted the whole UI isn't all that complex, but I have never needed a more complex "router" for anything
but to address your question more practically. to prevent the circular dependency you use data, meaning not putting your view functions into your routing data directly like :view home-page, but instead :view :home-page and then using a case like above or a multi method to render it
I use re-frame and I also use reitit, and Thomas is probably right that it could be overkill, but it is too late, I started years ago. I make use of :as-alias to deal with cyclical dependencies. These mostly arise when I need to refer to a re-frame event or subscription, or to a route name. All of these are namespaced keywords in my codebase, so :as-alias lets me refer to them properly without creating a cycle.
Appreciate the responses
In the Clojurescript REPL, editing source code triggers the built-in watch handler but results in an error "Watch compilation log available at: target/classes/js/watch.log" which amounts to Requested array size exceeds VM limit . It's a Clojurescript codebase with npm dependencies, target is bundle. Anyone saw this?
> In the Clojurescript REPL, editing source code [...] What does it mean, how do you edit source code via REPL?
Sorry, I meant after editing the source code in my editor (Emacs)
Does that error not have any stack trace? Do any of the namespace attempt to do something at the top level, other than defining things? Especially interested whether there's any printing going on anywhere.
[{:type java.lang.OutOfMemoryError
:message Requested array size exceeds VM limit
:at [java.util.Arrays copyOf Arrays.java 3537]}]
:trace
[[java.util.Arrays copyOf Arrays.java 3537]
[java.lang.AbstractStringBuilder ensureCapacityNewCoder AbstractStringBuilder.java 282]
[java.lang.AbstractStringBuilder append AbstractStringBuilder.java 897]
[java.lang.StringBuffer append StringBuffer.java 422]
[java.io.StringWriter write StringWriter.java 79]
[java.io.StringWriter append StringWriter.java 213]
[java.io.StringWriter append StringWriter.java 43]
[clojure.core$fn__7430 invokeStatic core_print.clj 218]
[clojure.core$fn__7430 invoke core_print.clj 212]
[clojure.lang.MultiFn invoke MultiFn.java 234]
[clojure.core$pr_on invokeStatic core.clj 3700]
[clojure.core$pr_on invoke core.clj 3694]
[clojure.core$print_sequential invokeStatic core_print.clj 66]
[clojure.core$fn__7436 invokeStatic core_print.clj 225]
[clojure.core$fn__7436 invoke core_print.clj 225]
[clojure.lang.MultiFn invoke MultiFn.java 234]
[clojure.core$pr_on invokeStatic core.clj 3700]
[clojure.core$pr_on invoke core.clj 3694]
[clojure.core$print_prefix_map$fn__7439 invoke core_print.clj 233]
[clojure.core$print_sequential invokeStatic core_print.clj 66]
[clojure.core$print_prefix_map invokeStatic core_print.clj 229]
[clojure.core$print_map invokeStatic core_print.clj 238]
[clojure.core$fn__7468 invokeStatic core_print.clj 266]
[clojure.core$fn__7468 invoke core_print.clj 263]
[clojure.lang.MultiFn invoke MultiFn.java 234]
[clojure.core$pr_on invokeStatic core.clj 3700]
[clojure.core$pr_on invoke core.clj 3694]
[clojure.core$print_prefix_map$fn__7439 invoke core_print.clj 233]
[clojure.core$print_sequential invokeStatic core_print.clj 66]
[clojure.core$print_prefix_map invokeStatic core_print.clj 229]
[clojure.core$print_map invokeStatic core_print.clj 238]
[clojure.core$fn__7468 invokeStatic core_print.clj 266]]}
Watching paths: /home/daniel/Clojure/experiment/src/cljs
Ah, don't you just love stack traces that start nowhere. No idea what could be causing it but I'd try putting a break point in one of the printing-related functions in the stack trace. Won't help with the issue itself but at least it would give a clue where the printing happens.
looks like its trying to print something that is too large to print. could be something small that just has a reference to itself, e.g. an atom that contains itself.
I am exploring the "@xyflow/react" library, I was trying to do something silly. I removed the component and it's good now. I'll try something else. Thanks, folks!