karad / lein_template_descjop

A Leiningen template(Clojure/ClojureScript Project) for Web based desktop application with Electron (atom-shell).
http://descjop.org
394 stars 16 forks source link

`:jsload-callback` should call core/mount-root instead of start-descjop! #36

Open gadfly361 opened 6 years ago

gadfly361 commented 6 years ago

Hey, I think there is a subtle bug in the profile dev init files.

The :jsload-callback (effectively) calls core/init!; however, it should instead call core/mount-root. This is an important distinction, because the core/init! function should run things once when the application first loads, and core/mount-root should be called every time figwheel reloads.


Bug is here: https://github.com/karad/lein_template_descjop/blob/master/resources/leiningen/new/descjop/reagent__src__front__profile__dev__init.cljs#L10

:jsload-callback should instead call mount-root: https://github.com/karad/lein_template_descjop/blob/master/resources/leiningen/new/descjop/reagent__src__front__core.cljs#L10

karad commented 6 years ago

Thank you! I will check the bug, and try to fix if it has probrem.

gadfly361 commented 6 years ago

@karad Upon further inspection, this line here will also be problematic and I think it should likely be removed.

That line will effectively call the core/init! function on every figwheel reload because it is a direct function call in a namespace. A way around this is to instead call the core/init! function from your index.html file. You could do that by adding a line here with the core/init! function call.

An example of how to make such a function call from an index.html file can be seen here, which references this function here