om

Please ask the channel first, not @dnolen directly!
minhnh 2017-09-14T04:16:30.000173Z

hi, I'm a newbie. I don't know what the Om component means in om/component?

(defui HelloWorld
  Object
  (render [this]
    (dom/div nil "Hello, world!")))

(def hello (om/factory HelloWorld))
I tried:
(om/component? HelloWorld)
(om/component? hello)
Both commands returned false

levitanong 2017-09-14T08:14:49.000300Z

@minhnh om/component? actually checks for a component instance. For example,

(defui HelloWorld
  Object
  (render [this]
    (println (om/component? this))
    (dom/div nil "Hello, world!")))

;; true

minhnh 2017-09-14T08:15:57.000196Z

How can I get this outside render function

levitanong 2017-09-14T08:16:49.000187Z

If you’re using the repl, you can go (om/component? (om/class->any reconciler HelloWorld))

levitanong 2017-09-14T08:17:28.000021Z

om/class->any asks the reconciler for some instance (if there are several instances, it’ll return one of them) of the HelloWorld class.

levitanong 2017-09-14T08:18:20.000319Z

If you’re looking for a specific instance, (om/component? (om/ref->any reconciler [:something/by-id 0])), where [:something/by-id 0] is an ident

minhnh 2017-09-14T08:18:34.000356Z

👍 This is what I need. Thank you

levitanong 2017-09-14T08:19:25.000171Z

you’re welcome. ref->any can do more, but I’ll just leave this here for brevity. https://github.com/omcljs/om/wiki/Documentation-(om.next)#ref-any