1

Consider the following snippet of om code:

(fn [data owner]
    (reify
      om/IRender
      (render [_]
        (dom/p nil (:text data)))))

Question: Is the "Om component" this entire snippet, or is it merely the function's return value of the (reify ...) expression?

George
  • 6,927
  • 4
  • 34
  • 67
  • For me this is a function that returns an om component (you could see it as a constructor/factory). Not sure why it should matter though. – nha Feb 17 '16 at 15:44

1 Answers1

2

Generally, they are both referred to as the "component". The result of reify is the "object-y" thing, so in a sense it should be called the component, but the function is the thing that's named, so it's typically what's worth talking about.

Importantly, though, neither of these is a React component. Om creates and manages a React component for you. It's available here as owner.

Om Next removes this level of indirection, which helps with the terminology ambiguity a bit:

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

(def hello (om/factory HelloWorld))

In this Om Next code, HelloWorld is an actual React component class, and its instances (generated with the function hello) are actual React component objects.

Peeja
  • 13,683
  • 11
  • 58
  • 77
  • 1
    The Om Next version seems vastly superior/less confusing. And I thought Om Next and Om were the same thing. I should probably ditch Om completely, and just learn Om Next. Would you agree? – George Feb 17 '16 at 16:58
  • 2
    Yes, I'd say if you're starting from scratch today, you may as well learn Om Next, unless you need it immediately for production use. It's still not released as "production-ready", but it's expected to be within the next month or two (though, of course, software is hard to estimate). – Peeja Feb 18 '16 at 01:06