Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A component that implements IQuery needs data returned, otherwise even statically defined dom elements do not get rendered. #891

Open
livtanong opened this issue Sep 21, 2017 · 0 comments

Comments

@livtanong
Copy link
Contributor

(defmulti read om/dispatch)

(defmethod read :default
  [{:keys [state]} k _]
  (let [st @state]
    {:value (get st k)}))

(defmethod read :foo
  [{:keys [state query]} k _]
  (let [st @state]
    (if-let [d (get st k)]
      {:value (when-let [d (get st k)]
                (om/db->tree query d st))}
      {:remote true})))

(defui SomeComponent
  static om/IQuery
  (query [_]
    [:foo
     ;; The text in the render function will only show up if either :foo has a value, or :bar is added to this query.
     ])
  Object
  (render [this]
    (dom/div nil "No matter what, this should render")))

(def parser (om/parser {:read read}))

(def reconciler
  (om/reconciler
   {:parser parser
    :state {:bar 42}}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant