The :hoplon: ClojureScript Web Framework - http://hoplon.io/

@flyboarder is this like a "lifecycle" thing for components, or a way to categorise data associated with the component?

flyboarder 2018-01-08T04:56:31.000054Z

@thedavidmeister a state machine for elements i guess


ok so you're moving through each of these states in response to something

flyboarder 2018-01-08T04:59:36.000076Z



looks to me like the lifecycle of async data (e.g. from user input or remote server) rather than a DOM component


e.g. i'm working on a simple "read more" popdown icon atm and it looks like this:


(h/defelem vertical
 [{:keys [expand? current-el? enabled?]}]
 (let [expand? (or expand? (j/cell false))
       current-el? (or current-el? (j/cell false))
       enabled? (or enabled? (j/cell true))]
  ; el gaining current status should also expand but losing current should not
  ; hide automatically
  (h/do-watch current-el?
   (fn [_ n]
    (when (and n @enabled?)
     (reset! expand? true))))

   :garden {:cursor :pointer}

   (h/if-tpl enabled?
     ; current-el? uses click so we do here as well to avoid async issues
     :click (fn [e]
             (swap! expand? not)
             (wheel.dom.events/stop-propagation e))
     (icons.hoplon/icon "#more"))

    (h/div :class "icon-space")))))


the states are focussed on managing whether the current element is in focus, whether the icon should display, whether the content is currently expanded, etc.