Skip to content

Instantly share code, notes, and snippets.

@txus
Created December 9, 2015 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save txus/90c9a4df121a6ad826b8 to your computer and use it in GitHub Desktop.
Save txus/90c9a4df121a6ad826b8 to your computer and use it in GitHub Desktop.
Reconciler can't normalize data
(defui RootView
static om/IQuery
(query [this]
(let [map-props (om/get-query map-component/MapView)]
`[{:map-props ~map-props}])))
(defui MapView
static om/IQuery
(query [this]
(let [cluster-query (om/get-query ClusterView)]
`[{:clusters ~cluster-query}])))
(defui ClusterView
static om/Ident
(ident [this {:keys [id]}]
[:cluster/by-id id])
static om/IQuery
(query [this]
(let [parking-spot-query (om/get-query ParkingSpotView)]
`[:id {:parking-spots ~parking-spot-query}]))))
(defui ParkingSpotView
static om/Ident
(ident [this {:keys [id]}]
[:parking-spot/by-id id])
static om/IQuery
(query [this]
[:id :latitude :longitude])))
;; the initial data:
(def init-data
{:parking-spots [{:id "parkingspot1" :latitude 49.5337868906 :longitude 10.9932439499}
{:id "parkingspot2" :latitude 50.0322684609 :longitude 11.472756837}
{:id "parkingspot3" :latitude 49.7504798885 :longitude 11.0595198813}
{:id "parkingspot4" :latitude 50.0487723441 :longitude 10.059378956}]
:clusters [{:id 0 :parking-spots [{:id "parkingspot4"} {:id "parkingspot3"}]}
{:id 1 :parking-spots [{:id "parkingspot2"} {:id "parkingspot1"}]}]})
@txus
Copy link
Author

txus commented Dec 9, 2015

The root query is:

[{:map-props [{:clusters [:id {:parking-spots [:id :latitude :longitude]}]}]}]

The problem is that the reconciler doesn't seem to normalize the data, even though there are proper Idents in place and the shape of the data seems ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment