In the following code I would expect main-panel to be called when the target of
::selected-page changes but it isn't.
I can confirm state has changed in the console.logs in 'application', but I
don't see the console.log in 'main-panel'.
I fully expect it is a numpty mistake but I can't see it - any thoughts:
(register-sub
::selected-page
(fn [db] (reaction (:page @db))))
(register-sub
::db
(fn [db] (reaction @db)))
(defn main-panel []
(let [page (subscribe [::selected-page])]
(fn []
(js/console.log "****** PAGE is " (clj->js @page))
(condp = @page
state/AddPatientPage (add-patient/page {})
state/PatientSearchPage (search/page)
[:div (str "Unknown " page)]))))
(defn application
[]
(let [need-to-login?
;; TODO - temporarily removed for efficiency
(atom false)
#_(subscribe [:need-to-login?])
db (subscribe [::db])
selected-page (subscribe [::selected-page])
initialised? (subscribe [::initialised?])
problems-with-server? (subscribe [::problems-with-server?])
show-main-app? (reaction (and (not @need-to-login?)
(not @problems-with-server?)))]
(fn []
(js/console.log "DATABASE: " (clj->js @db))
(js/console.log "SELECTED-PAGE: " (clj->js @selected-page))
(if @initialised?
(cond->
[:div]
@problems-with-server? (conj [:div.server-disconnected
"SERVER ERROR"])
@need-to-login? (conj [login/login-overlay])
@show-main-app? (conj [main-panel]))
[:div "INITIALISING...."]))))
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.