{"push_id":1196426121,"size":1,"distinct_size":1,"ref":"refs/heads/responsive-layout-attributes-micha","head":"f08d23f539c2e631be0827e17d3f7a7590c191ae","before":"b3577d59328bb42e92627faf1a3d9b9e5f9b7def","commits":[{"sha":"f08d23f539c2e631be0827e17d3f7a7590c191ae","author":{"name":"Micha Niskin","email":"1d71f8e2e45d83da97e2751fdd01441232e1a584@gmail.com"},"message":"Add ICustomAttribute protocol and definterval macro\n\n- The ICustomAttribute protocol provides the interface that custom\n  attribute types must implement. It comprises one method:\n\n      (-do! [this dom-element attribute-value])\n\n  The method is called by hoplon core when an attribute is added to an\n  element. It's the responsibilty of the ICustomAttribute implementation\n  to set up any reactive bindings etc.\n\n  The protocol has been extended to the Keyword type, providing the\n  existing hoplon custom attribute implementation, e.g. the do! and on!\n  multimethods and reactive binding to javelin cells, etc.\n\n  The benefit of this approach is that you can have first-class objects\n  as attribute types now, namespaced vars, that implement any new type\n  of attribute behavior.\n\n  An example of how you would create your own attribute type:\n\n      (ns my.lib\n        (:require [hoplon.core :as h]\n                  [javelin.core :as j]))\n\n      (defn make-debug-attr [k]\n        (reify hoplon.core/ICustomAttribute\n          (-do! [this e v]\n            (.log js/console (str \"setting: \" k \" on \" e))\n            (cond (fn? v)   (.on (js/jQuery e) k v)\n                  (cell? v) (h/do-watch v #(-do! this e %2))\n                  :else     (.log js/console \"setting:\" k v)))))\n\n      (def --layout (make-debug-attr :layout))\n\n      ...\n\n  And you'd use that attribute like this:\n\n      (ns my.app\n        (:require [hoplon.core :as h]\n                  [javelin.core :as j]\n                  [my.lib :as l :refer [--layout px]))\n\n      ...\n\n      (h/html\n        (h/body\n          (h/h1 --layout [10 20 30 px] \"hello world!\")))\n\n- The definterval macro is like defonce for js setInterval. The timer is\n  canceled and replaced when code is reloaded. Storing the timer handle\n  in a var is also handy if you need to cancel it yourself.","distinct":true,"url":"https://api.github.com/repos/hoplon/hoplon/commits/f08d23f539c2e631be0827e17d3f7a7590c191ae"}]}
{"actor":{"display_login":"micha"}}