Last active
May 27, 2016 08:52
-
-
Save hkjels/ec2bfa514e9c17291d9b11ef3cf76785 to your computer and use it in GitHub Desktop.
There are no remote calls being made
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmethod read :lifelines/title | |
[{:keys [state]} k _] | |
{:value "Boooom!"}) | |
(defmethod read :lifelines/items | |
[{:keys [state ast] :as env} k _] | |
(let [st @state] | |
(if (contains? st k) | |
{:value (get st k)} | |
{:remote true}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmethod read :route/handler | |
[{:keys [state query]} k _] | |
(let [st @state] | |
{:value (get st k)})) | |
(defmethod read :route/data | |
[{:keys [parser query ast target] :as env} k params] | |
{:value (parser env query target)}) | |
(defmethod write 'change/route! | |
[{:keys [state component]} _ {:keys [handler]}] | |
"Swaps the route-handler and injects it's query into the root-component" | |
{:value {:keys [:route/handler :route/data]} | |
:action #(let [query (om/get-query (route->view (first handler)))] | |
(swap! state assoc :route/handler handler) | |
(om/set-query! component {:params {:route/data query}}))}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def route->view | |
"Maps a route-keyword to the corresponding view" | |
{:app/home Home | |
:app/lifelines Lifelines}) | |
(def route->factory | |
"Maps a route-keyword to the corresponding view-factory" | |
{:app/home home | |
:app/lifelines lifelines}) | |
(defui App | |
static om/IQueryParams | |
(params [this] {:route/data []}) | |
static om/IQuery | |
(query [this] '[:route/handler {:route/data ?route/data}]) | |
Object | |
(componentWillMount [this] | |
(let [{:keys [route/handler]} (om/props this) | |
initial-query (om/get-query (route->view (first handler)))] | |
(om/set-query! this {:params {:route/data initial-query}}))) | |
(render [this] | |
(let [{:keys [route/handler route/data]} (om/props this) | |
current-view (get route->factory (first handler))] | |
(html [:div.container | |
(header data) | |
[:main (current-view data)]])))) |
In short. Boooom!
is outputted, but not my :lifeline/items
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, if I mount the
Lifeline
-component directly as root, the remote calls are made. But I'm trying to achieve some routing and thought I could just manually run my parser, but thensend
is never invoked.