Skip to content

Instantly share code, notes, and snippets.

@otwieracz
Created January 22, 2020 19:17
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 otwieracz/3e39cfec5e7f8c151b37b2268e70393b to your computer and use it in GitHub Desktop.
Save otwieracz/3e39cfec5e7f8c151b37b2268e70393b to your computer and use it in GitHub Desktop.
(def ui-wire (comp/factory Wire {:keyfn :wire/id}))
(defsc WireList [_this {:keys [wires]}]
{:query [{:wires (comp/get-query Wire)}]
;; :ident :wire-list/id
}
(println (str "Wires on WireList are: " wires))
(ui-table {:striped true :hover true}
(thead
(tr
(th "Label")
(th "Color")
(th "Terminals")
(th "Saved?")
))
(tbody
(map ui-wire wires))))
(def ui-wire-list (comp/factory WireList #_{:keyfn :wire-list/id}))
(defsc Root [this {:keys [wires]}]
{:query [{:wires (comp/get-query Wire)}]
:initial-state {}}
(div
(when wires
(println (str "Wires on Wires are: " wires))
(div
(ui-wire-list wires)
(ui-button {:onClick (fn [] (comp/transact! this [(mutations/add-wire {:wire-list/id :my-wires :wire/id 2})]))} "foo")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment