Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
migrate events to cljc
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed Oct 27, 2020
1 parent d2d0747 commit 5407292
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/main/shadow/experiments/grove/components.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@
(supports? [this next]
(and (component-init? next)
(let [other (.-component ^ComponentInit next)]
(identical? config other))))
(identical? config other))
(let [custom-check (-> config .-opts (get :supports?))]
(or (nil? custom-check)
(custom-check args (.-args next))))))

(dom-sync! [this ^ComponentInit next]
(. config (check-args-fn this args (.-args next)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
;; each query will figure out on its own if if actually triggers an update
;; FIXME: figure out if this can be smarter
(reduce
(fn [_ ^IQuery query]
(fn [_ #?(:clj query :cljs ^IQuery query)]
(query-refresh! query))
nil
queries)))
Expand All @@ -103,7 +103,7 @@
(let [^function handler-fn (get event-config ev-id)]

(if-not handler-fn
(js/console.warn "no event handler for" ev-id tx env)
(throw (ex-info "unhandled event" {:ev-id ev-id :tx tx}))

(let [before @data-ref

Expand All @@ -120,7 +120,7 @@
(fn [_ fx-key value]
(let [fx-fn (get fx-config fx-key)]
(if-not fx-fn
(js/console.warn "invalid fx" fx-key value)
(throw (ex-info "invalid fx" {:fx-key fx-key :fx-value value}))
(let [transact-fn
(fn [fx-tx]
;; FIXME: should probably track the fx causing this transaction and the original tx
Expand Down
2 changes: 1 addition & 1 deletion src/main/shadow/experiments/grove/history.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns shadow.experiments.grove.history
(:require
[shadow.experiments.grove :as sg]
[shadow.experiments.grove.runtime.worker-engine :as eng]
[shadow.experiments.grove.worker-engine :as eng]
[clojure.string :as str])
(:import [goog.history Html5History]))

Expand Down
4 changes: 2 additions & 2 deletions src/main/shadow/experiments/grove/http_fx.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns shadow.experiments.grove.http-fx
(:require
[clojure.string :as str]
[shadow.experiments.grove.runtime.worker :as sw]))
[shadow.experiments.grove.worker :as sw]))

;; this is using XMLHttpRequest. no intent on making this usable with anything else.
;; might split this up into different namespace so there could be one variant using js/fetch
Expand Down Expand Up @@ -210,7 +210,7 @@
(read-fn (.-responseText xhr-req))))

(defn parse-transit [env ^js xhr-req]
(let [read-fn (:shadow.experiments.grove.runtime.worker/transit-read env)]
(let [read-fn (:shadow.experiments.grove.worker/transit-read env)]
(when-not read-fn
(throw (ex-info "received a transit response but didn't have transit-read fn" {})))
(read-fn (.-responseText xhr-req))))
Expand Down
2 changes: 1 addition & 1 deletion src/main/shadow/experiments/grove/preload.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[shadow.remote.runtime.api :as p]
[shadow.remote.runtime.shared :as shared]
[shadow.cljs.devtools.client.shared :as cljs-shared]
[shadow.experiments.grove.runtime.worker :as sw]
[shadow.experiments.grove.worker :as sw]
[shadow.experiments.grove.db :as db]
[shadow.experiments.grove.runtime :as rt]
[clojure.core.protocols :as cp]))
Expand Down
1 change: 1 addition & 0 deletions src/main/shadow/experiments/grove/runtime.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(ns shadow.experiments.grove.runtime)

0 comments on commit 5407292

Please sign in to comment.