diff --git a/src/main/example/core.clj b/src/main/example/core.clj index 6854d91..6380b22 100644 --- a/src/main/example/core.clj +++ b/src/main/example/core.clj @@ -21,27 +21,27 @@ ;; pages (defpage home-page - (html->str - [:main - [:div - [:input {:data-bind "msg"}] - [:div {:data-text "$msg"}] - [:button {:data-on-click (->expr (@post ~hello-world ~keep-open))} - "click for text animation"]] - [:button {:data-on-click (->expr (@post ~page-2))} - "go to page 2"]])) + (html->str + [:main + [:div + [:input {:data-bind "msg"}] + [:div {:data-text "$msg"}] + [:button {:data-on-click (->expr (@post ~hello-world ~keep-open))} + "click for text animation"]] + [:button {:data-on-click (->expr (@post ~page-2))} + "go to page 2"]])) (defpage page-2 (html->str - [:main - [:div + [:main + [:div [:p "this is page2"] - [:button + [:button {:data-on-click (->expr (@post ~say-hi))} "say hi to everyone"]] - [:button {:data-on-click (->expr (@post ~home-page))} - "go back to home"]])) + [:button {:data-on-click (->expr (@post ~home-page))} + "go back to home"]])) ;; http app server (def routes diff --git a/src/main/example/utils.clj b/src/main/example/utils.clj index 154a286..fdaf424 100644 --- a/src/main/example/utils.clj +++ b/src/main/example/utils.clj @@ -131,7 +131,7 @@ route-str-sse (str "/sse" route-str)] `(let [view# (fn [_#] ~@body)] - + (add-route! ~route-str (fn [request# respond# _#] (page request# respond# ~route-str view#))) @@ -142,21 +142,21 @@ (defn app-routes ([] - (->> @!ma-routes - vec)) + (->> @!ma-routes + vec)) ([index-route] (concat (app-routes) - [["/" (@!ma-routes index-route)]]))) + [["/" (@!ma-routes index-route)]]))) (defmacro defaction [action-sym args & body] (let [url (str "/sse/" action-sym)] `(let [sse-handler# (fn [request# respond# raise_#] - (respond# + (respond# (->sse-response - request# - {on-open (fn ~args (d*/with-open-sse ~(get args 0) - ~@body))})))] + request# + {on-open (fn ~args (d*/with-open-sse ~(get args 0) + ~@body))})))] (add-route! ~url sse-handler#) (def ~action-sym ~url))))