venantius / accountant

ClojureScript navigation for single-page applications, made simple.
Eclipse Public License 1.0
250 stars 39 forks source link

Examples #4

Closed coyotespike closed 9 years ago

coyotespike commented 9 years ago

Thanks for putting together this library. Unfortunately, I wasn't able to get it to work though I'm interested in doing so.

I ran lein new reagent myproject. I added the necessary calls to my project.clj and core.cljs. Running lein figwheel resulted in large stack traces.

I then copied the "only namespace" ;-), and used it in my project like this:

(defn init! []
  (accountant/configure-navigation!)
;  (hook-browser-navigation!)
  (mount-root))

but this resulted in the console error: Error: Assert failed: Invalid Hiccup form: [nil] (in myproject.core.current_page) (valid-tag? tag)

I then copied this example: https://gist.github.com/city41/aab464ae6c112acecfe1

and that worked.

A working example could demonstrate proper usage, and maybe how this library differs from the example above, and could clarify how accountant/navigate! is meant to be used.

venantius commented 9 years ago

Could you provide the full stacktrace you ran into? I'm afraid the console error you've included doesn't leave me a lot to go on.

coyotespike commented 9 years ago

You know, I think the stacktrace problem may have been between my chair and my keyboard - I named that project accountant and I think that screwed everything up!

Here's a repo with a minimal Reagent project, where I tried to use the Accountant library. It produces the error, which I also get if I copy the file within my project. https://github.com/coyotespike/accountant-test

venantius commented 9 years ago

Your problem has nothing to do with accountant. It has to do with the fact that at load time session/get is nil. Try replacing lines 21:22 of testme.core.cljs with

(defn current-page []
  [:div [:h2 "stuff"]])

and it loads just fine.

coyotespike commented 9 years ago

Thanks very much for the clarification! I prefer your full-fledged version to the gist I was using earlier, so that's great.