Hacker News new | ask | show | jobs
by masklinn 4487 days ago
* did-mount is a mapping to React's componentDidMount[0] lifecycle method (and, in Om, part of the IDidMount protocol[1])

* reify is the creation of an anonymous type instance, implementing 1..n protocols (not entirely dissimilar to an anonymous class in java). This could also have been done with a deftype (no difference in efficiency, but Om's creator seems to prefer reify):

    (deftype Widget [data owner]
      om/IRender
      (render [this]
        ; render code here
        )
      om/IDidMount
      (did-mount [this node]
        ; mount code here
        )
* peek's a bit more complex because it requires knowledge of interesting features (?) of Clojure collections: all clojure collections are immutable, and often built with conj(oin). conj "adds an item to a collection", but where it does so depends on the collection (and its efficiency profile): (conj '(1 2 3) 0) -> '(0 1 2 3) but (conj [1 2 3] 0) -> [1 2 3 0] (lists can be efficiently extended from the head, vectors from the tail). `peek` essentially returns the last conj'd item, so on lists it's equivalent to `first`, on vectors it's equivalent to `last` (but faster)

[0] http://facebook.github.io/react/docs/component-specs.html#mo...

[1] https://github.com/swannodette/om/wiki/Documentation#wiki-id...