Closed caryfitzhugh closed 9 years ago
I ended up doing what I proposed above. Create a paths.cljs namespace. All these puppies produce a string.
(defn article-path [article-id & args]
(as-path "articles" article-id args))
And pass those into the defroute macro.
(defroute (p/article-path :aid) [aid]
(articles/show-article app-state/current aid))
Only sticky part was that I had to write some functions to dispatch and prepend with the "#" in certain situations. Other than that...
Don't know if anyone else cares, but I'll leave it here in the comments so maybe it'll help someone googling for "secretary circular dependencies"
Hi
I have an app which uses Secretary to define the routes for the system.
so routes.cljs has the route definitions.
routes.cljs references some controller namespaces in order to route people to the right controller when things change.
Additionally, controllers sometimes need to send people places.
routes -> controller -> routes
This is a circular dependency.
I believe there's no way around it since in my case the things which are accepting being routed-to also want to route people to other places.
In my earlier home-grown efforts I had split paths and routes into two files so that I could avoid this.
e.g.
Is there something like this in Secretary / has someone come up with any solutions other than "reorganize your code"?
I looked and there seemed to only be the "mother-macro" defroute, and I wasn't clear on how to split that apart.
This seems like such a common issue that I hope there is something simple...
like:
Something along those lines. Thanks!