Skip to content

Instantly share code, notes, and snippets.

@hugoduncan
Last active February 7, 2016 04:03
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 hugoduncan/2bd2d57b7eb42dc7b740 to your computer and use it in GitHub Desktop.
Save hugoduncan/2bd2d57b7eb42dc7b740 to your computer and use it in GitHub Desktop.
Using a React Native ListView with om.next
(list-view
{:dataSource (clone-with-rows
data-source
(clj->js
(mapv #(assoc % :omcljs$meta (pr-str (meta %)))
objects)))
:renderRow (fn objects-render-r-row [row section-id row-id]
(let [row (j->c row)
m (:omcljs$meta row)
m (if m (reader/read-string m))
row (with-meta (dissoc row :omcljs$meta) m)]
(with-om-vars this
(objects-row row))))
:style (:list styles)})
(defmacro with-om-vars [component & body]
;; these should match the 'render case in reshape-map
`(let [this# ~component
reconciler# (or om.next/*reconciler*
(om.next/get-reconciler this#))
depth# (or om.next/*depth* (inc (om.next/depth this#)))
shared# (or om.next/*shared* (om/shared this#))
instrument# (or om.next/*instrument* (om/instrument this#))
parent# (or om.next/*parent* this#)]
(binding [om.next/*reconciler* reconciler#
om.next/*depth* depth#
om.next/*shared* shared#
om.next/*instrument* instrument#
om.next/*parent* this#]
~@body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment