Skip to content

Commit

Permalink
add assertions for dispatching functions
Browse files Browse the repository at this point in the history
  • Loading branch information
roman01la committed Jul 27, 2018
1 parent 7a3eaf5 commit fe47f11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example/counter/core.cljs
Expand Up @@ -6,9 +6,17 @@
[cljs.spec.alpha :as s]
[expound.alpha :as expound]))

;;
;; enable printing readable specs
;;

(s/check-asserts true)
(set! s/*explain-out* expound/printer)

;;
;; spec effects
;;

(s/def :http/url string?)
(s/def :http/on-ok keyword?)
(s/def :http/on-failed keyword?)
Expand Down Expand Up @@ -62,6 +70,7 @@
:border "1px solid blue"}}]
[:button {:on-click #(citrus/dispatch! r :github :fetch-repos @username)
:style {:border-radius "5px"
:outline "none"
:font-size "11px"
:background-color "blue"
:color "#fff"
Expand Down
5 changes: 5 additions & 0 deletions src/citrus/core.cljs
Expand Up @@ -64,6 +64,7 @@
event - a dispatch value of a method defined in the controller
args - arguments to be passed into the controller"
[reconciler controller event & args]
{:pre [(instance? r/Reconciler reconciler)]}
(r/dispatch! reconciler controller event args))

(defn dispatch-sync!
Expand All @@ -78,6 +79,7 @@
event - a dispatch value of a method defined in the controller
args - arguments to be passed into the controller"
[reconciler controller event & args]
{:pre [(instance? r/Reconciler reconciler)]}
(r/dispatch-sync! reconciler controller event args))

(defn broadcast!
Expand All @@ -91,6 +93,7 @@
event - a dispatch value of a method defined in the controller
args - arguments to be passed into the controller"
[reconciler event & args]
{:pre [(instance? r/Reconciler reconciler)]}
(r/broadcast! reconciler event args))

(defn broadcast-sync!
Expand All @@ -104,6 +107,7 @@
event - a dispatch value of a method defined in the controller
args - arguments to be passed into the controller"
[reconciler event & args]
{:pre [(instance? r/Reconciler reconciler)]}
(r/broadcast-sync! reconciler event args))


Expand All @@ -120,4 +124,5 @@
([reconciler path]
(subscription reconciler path identity))
([reconciler path reducer]
{:pre [(instance? r/Reconciler reconciler)]}
(c/reduce-cursor-in reconciler path reducer)))

0 comments on commit fe47f11

Please sign in to comment.