Liking cljdoc? Tell your friends :D

Wire is a Clojure(Script) library for sanely managing component communication

Wire is still a proof of concept and is undergoing breaking changes.

Simple usage

(require '[wire.core :as w])

;; Create new wire and wire tap for a message. Any change functions
;; (tap, lay) are immutable and create a new wire.
(def basic-wire 
  (-> (w/wire)
      (w/tap :hello 
        (fn [{:keys [msg user]}] 
          (println (str "hello " msg " from " (or user "nobody")))))))

;; Send message up the wire
(w/act basic-wire :hello {:msg "world"}) ;; => hello world from nobody

;; Create a new wire with extra data laid 
(def richs-wire
  (w/lay basic-wire nil {:user "rich"}))

;; Send message as you would, with extra laid context
(w/act richs-wire :hello {:msg "world"}) ;; => hello world from rich

;; The initial wire is untouched
(w/act basic-wire :hello {:msg "world"}) ;; => hello world from nobody

Wire pairs well with Show. Check out wired-show to see how you can easily use wire with dom objects.

License

Copyright © 2018 controlroom.io

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

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close