https://github.com/swannodette/om/tree/master/examples/unmount
The unmounting happens on lines 30 through 32: https://github.com/swannodette/om/blob/master/examples/unmount/src/core.cljs#L30-L32 (render [_] (dom/div nil (if (= (:widget data) :a) (om/build widget-a {}) (om/build widget-b {})) (dom/button #js {:onClick (fn [e] (om/transact! data :widget {:a :b :b :a}))} "Switch!"))) When the condition of the if statement changes, either widget-a or widget-b gets built. Consider the following flow of events: (:widget data) starts off as :a, widget-a init-state is called, will-mount, render, did-mount. User clicks the button, (:widget data) is changed to :b, widget-a will-unmount is called, widget-b init-state, will-mount, render, did-mount are called. User clicks the button again, (:widget data) is changed to :a, widget-b will-unmount is called, widget-a will-mount, render, did-mount are called. I'm ignoring the other lifecycle functions (should-update, will-receive-props, will-update, did-update, display-name), generally the will-* functions get called before render and the did-* functions get called after render. I'm also conflating render and render-state as they're basically the same thing. On 26 July 2014 07:46, John Chijioke <[email protected]> wrote: > Please is there a valid example somewhere that illustrates unmounting an > om component from the DOM? > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
