reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
394 stars 55 forks source link

Make the pages reloadable? #86

Closed bsteuber closed 8 years ago

bsteuber commented 8 years ago

In the route definitions, if you replace e.g. the #'home-page by 'home-page, changes to the page components will automatically reload them when using figwheel. Would this have any drawbacks?

yogthos commented 8 years ago

The components should reload currently with figwheel already. Is this not the case for you?

bsteuber commented 8 years ago

Nope if I change a component it's not being reloaded, I thought that's because the route definition is unchanged and due to the #' it keeps its pointer to the old version. When removing the # it works like I expected. Is it different on your machine?

Dmitri Sotnikov notifications@github.com schrieb am Do., 29. Okt. 2015 13:58:

The components should reload currently with figwheel already. Is this not the case for you?

— Reply to this email directly or view it on GitHub https://github.com/reagent-project/reagent-template/issues/86#issuecomment-152172727 .

yogthos commented 8 years ago

The components reload as expected when I edit the namespace and save it. How are you updating the component in your case?

Using the #' creates a var that should be resolved to the new component each time. The reason it's used is so that when a page is in a different namespace it still gets resolve correctly and reloads. If you keep the pointer to the old version then that gets lost during the reload.

bsteuber commented 8 years ago

Oh you're right - the reloading only fails when I do "lein figwheel devcards". Is that a bug or expected behavior, meaning the devcard build will simply only reload the devcards and nothing else?

On Thu, Oct 29, 2015 at 2:05 PM Dmitri Sotnikov notifications@github.com wrote:

The components reload as expected when I edit the namespace and save it. How are you updating the component in your case?

Using the #' creates a var that should be resolved to the new component each time. The reason it's used is so that when a page is in a different namespace it still gets resolve correctly and reloads. If you keep the pointer to the old version then that gets lost during the reload.

— Reply to this email directly or view it on GitHub https://github.com/reagent-project/reagent-template/issues/86#issuecomment-152174046 .

yogthos commented 8 years ago

Yeah, so those are two separate builds. When you're running the devcards build you should reference the pages in the devcards namespace, e.g:

(ns app.cards
  (:require [reagent.core :as reagent :refer [atom]]
            [reagent.session :as session]
            ;;reference the core namespace
            [app.core :as core])
  (:require-macros
   [devcards.core
    :as dc
    :refer [defcard defcard-doc defcard-rg deftest]]))

(defcard-rg first-card
  ;;render the page from the core namespace
  [core/home-page])

The updates in the core/home-page should now be reflected live in the devcard.

bsteuber commented 8 years ago

That makes sense, thx for your quick help!

On Thu, Oct 29, 2015 at 5:29 PM Dmitri Sotnikov notifications@github.com wrote:

Yeah, so those are two separate builds. When you're running the devcards build you should reference the pages in the devcards namespace, e.g:

(ns app.cards (:require [reagent.core :as reagent :refer [atom]] [reagent.session :as session] ;;reference the core namespace [app.core :as core]) (:require-macros [devcards.core :as dc :refer [defcard defcard-doc defcard-rg deftest]]))

(defcard-rg first-card ;;render the page from the core namespace [core/home-page])

The updates in the core/home-page should now be reflected live in the devcard.

— Reply to this email directly or view it on GitHub https://github.com/reagent-project/reagent-template/issues/86#issuecomment-152236089 .

yogthos commented 8 years ago

no prob, and I updated the template to add the home-page in the devcards as an example