Skip to content

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

Open
@livtanong

Description

@livtanong
(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}}))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions