Skip to content

Commit 4781e4b

Browse files
committed
remove cljs-ajax dependency
1 parent bb3f908 commit 4781e4b

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

deps.edn

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
:deps {akiroz.re-frame/storage {:mvn/version "0.1.4"}
33
binaryage/devtools {:mvn/version "1.0.7"}
44
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
5-
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
65
clj-kdtree/clj-kdtree {:git/url "https://github.com/abscondment/clj-kdtree.git"
76
:sha "5ec321c5e8006db00fa8b45a8ed9eb0b8f3dd56d"
87
:deps/manifest :deps}

src/user.cljs

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns user
22
(:require
3-
[ajax.core]
43
[clojure.math]
54
[clojure.string :as str]
65
[config :as config]
@@ -318,31 +317,26 @@
318317

319318
(def ^:export version config/version)
320319

321-
#_{:clj-kondo/ignore [:unresolved-var]}
322320
(comment
323321
(dotimes [x 25]
324322
(circle [(+ (* x 30) 40) (+ (* (js/Math.sin x) 10) 200)]
325323
10
326324
{:fill (str "hsl(" (* x 10) " ,50% , 50%)")}))
327325

328-
(ajax.core/GET
329-
"https://api.thecatapi.com/v1/images/search"
330-
{:response-format (ajax.core/json-response-format {:keywords? true})
331-
:handler (fn [response]
332-
(let [{:keys [width height url]} (first response)]
333-
(image 0 0 [width height] url)))})
334-
335-
(defn kitty [x y width height]
336-
(ajax.core/GET
337-
"https://api.thecatapi.com/v1/images/search"
338-
{:response-format (ajax.core/json-response-format {:keywords? true})
339-
:handler (fn [response]
340-
(image [x y]
341-
width
342-
height
343-
(:url (first response))
344-
{:preserveAspectRatio "xMidYMid slice"}))}))
345-
346-
(dotimes [x 8]
347-
(dotimes [y 6]
348-
(kitty (* x 100) (* y 100) 100 100))))
326+
(defn ^:export kitty [[x y] width height]
327+
(-> (js/fetch "https://api.thecatapi.com/v1/images/search" #js{:method "GET"})
328+
(.then (fn [response]
329+
(-> (.json response)
330+
(.then (fn [body]
331+
(let [body (js->clj body :keywordize-keys true)]
332+
(image [x y]
333+
width
334+
height
335+
(:url (first body))
336+
{:preserveAspectRatio "xMidYMid slice"})))))))))
337+
338+
(dotimes [x 5]
339+
(dotimes [y 5]
340+
(kitty [(* x 100) (* y 100)] 100 100)))
341+
342+
#())

0 commit comments

Comments
 (0)