Add cljs-ajax plugin
This commit is contained in:
parent
0c0d5afacd
commit
f5b014864f
3
deps.edn
3
deps.edn
|
@ -7,7 +7,8 @@
|
|||
reagent/reagent {:mvn/version "1.0.0"}
|
||||
cljsjs/react {:mvn/version "17.0.2-0"}
|
||||
cljsjs/react-dom {:mvn/version "17.0.2-0"}
|
||||
cljsjs/react-dom-server {:mvn/version "17.0.2-0"}}
|
||||
cljsjs/react-dom-server {:mvn/version "17.0.2-0"}
|
||||
cljs-ajax/cljs-ajax {:mvn/version "0.8.3"}}
|
||||
|
||||
:aliases
|
||||
{:dev
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
:modules
|
||||
{:scittle {:entries [scittle.core]}
|
||||
:scittle.reagent {:entries [scittle.reagent]
|
||||
:depends-on #{:scittle}}
|
||||
:scittle.cljs-ajax {:entries [scittle.cljs-ajax]
|
||||
:depends-on #{:scittle}}}
|
||||
:build-hooks [(shadow.cljs.build-report/hook)]
|
||||
:output-dir "resources/public/js"
|
||||
|
|
14
src/scittle/cljs_ajax.cljs
Normal file
14
src/scittle/cljs_ajax.cljs
Normal file
|
@ -0,0 +1,14 @@
|
|||
(ns scittle.cljs-ajax
|
||||
(:require [ajax.core :as ajx]
|
||||
[sci.core :as sci]
|
||||
[scittle.core :as scittle]))
|
||||
|
||||
(def ans (sci/create-ns 'ajax.core nil))
|
||||
|
||||
(def ajax-namespace
|
||||
{'GET (sci/copy-var ajx/GET ans)
|
||||
'POST (sci/copy-var ajx/POST ans)})
|
||||
|
||||
(scittle/register-plugin!
|
||||
::ajax
|
||||
{:namespaces {'ajax.core ajax-namespace}})
|
|
@ -3,7 +3,8 @@
|
|||
(:require [goog.object :as gobject]
|
||||
[goog.string]
|
||||
[sci.core :as sci]
|
||||
[scittle.impl.error :as error]))
|
||||
[scittle.impl.error :as error]
|
||||
[cljs.reader :refer [read-string]]))
|
||||
|
||||
(clojure.core/defmacro time
|
||||
"Evaluates expr and prints the time it took. Returns the value of expr."
|
||||
|
@ -17,13 +18,16 @@
|
|||
|
||||
(def stns (sci/create-ns 'sci.script-tag nil))
|
||||
(def cljns (sci/create-ns 'clojure.core nil))
|
||||
(def rns (sci/create-ns 'cljs.reader nil))
|
||||
|
||||
(def namespaces
|
||||
{'clojure.core
|
||||
{'println println
|
||||
'prn prn
|
||||
'system-time system-time
|
||||
'time (sci/copy-var time cljns)}
|
||||
'time (sci/copy-var time cljns)
|
||||
'random-uuid random-uuid
|
||||
'read-string (sci/copy-var read-string rns)}
|
||||
'goog.object {'set gobject/set
|
||||
'get gobject/get}})
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
(def rns (sci/create-ns 'reagent.core nil))
|
||||
|
||||
(def reagent-namespace
|
||||
{'atom (sci/copy-var r/atom rns)})
|
||||
{'atom (sci/copy-var r/atom rns)
|
||||
'as-element (sci/copy-var r/as-element rns)})
|
||||
|
||||
(def rdns (sci/create-ns 'reagent.dom nil))
|
||||
|
||||
|
|
Loading…
Reference in a new issue