Skip to content

the-kenny/nom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nom

A Clojure library providing some utility-functions and -macros for Om.

Usage

(cancel-event [e])

Runs preventDefault and stopPropagation on event e.

(with-working [target & body])

A utility macro that sets the key :working? to true on target (a Om cursor or owner). Useful to disable forms while some operation (body) is running e.g. in a core.async go block.

defcomponent

A macro just like defcomponent from prismatic/om-tools but with less fancyness (no validation, no mixins). It will also wrap the body of render and render-state in sablono.core/html allowing you to write:

(defcomponent todo-item [todo]
  (render [_]
    [:li.todo {:class (:state todo)}
     [:.title (:title todo)]
     [:.text  (:text todo)]]))

Which will emit:

(defn todo-item [todo]
  (reify
    om/IDisplayName
    (display-name [_] "TodoItem")
    om/IRender
    (render [_]
      (html
       [:li.todo {:class (:state todo)}
        [:.title (:title todo)]
        [:.text  (:text todo)]]))))

You can find a short post on how this macro works and how it eliminates boilerplate on my Blog.

defcomponentmethod

Same as defcomponent but takes an extra dispatch-value arg and will emit a defmethod instead of defn.

License

Copyright © 2015 Moritz Ulrich

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Improve your Om with Nom

Resources

License

Stars

Watchers

Forks

Packages

No packages published