- om "0.8.0"
I have recently started learning om by using examples codes of om repository. Now, I am checking multi example and I can understand the behavior of this program.
After I clicked '+' button,
- First, "Even(or Odd) widget unmounting" is printed.
- Next, "Odd(or Even) widget mounting" is printed.
But when I added following code
(just change even-odd-widget defmulti
code to defn
code)
(defn test-widget
[props owner]
(reify
om/IWillMount
(will-mount [_]
(println "Test widget mounting"))
om/IWillUnmount
(will-unmount [_]
(println "Test widget unmounting"))
om/IRender
(render [_]
(dom/div nil
(dom/h2 nil (str "Test Widget: " (:my-number props)))
(dom/p nil (:text props))
(dom/button
#js {:onClick #(om/transact! props :my-number inc)}
"+")))))
and tried to use this function instead of test-widget
, as the result, there was no print message...
So what is the difference between defmulti and defn in this case? Is this bug or correct behavior?
Thanks in advance.