-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
remote.cljs
31 lines (27 loc) · 918 Bytes
/
remote.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(ns portal.shadow.remote
(:require [portal.client.web :as client]))
(goog-define port 0)
(defn get-port
"Get portal server port."
{:added "0.28.0"}
[]
(if-not (zero? port)
port
(let [error (js/Error.
(str "Portal server port is missing. "
"Did you add the portal.shadow.remote/hook to :build-hooks in shadow-cljs.edn? \n"
"See https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks for more info."))]
(.error js/console error)
(throw error))))
(defn submit
"Tap target function.
Usage:
(add-tap portal.shadow/submit)
(remove-tap portal.shadow/submit)"
{:added "0.28.0"
:see-also ["portal.api/submit"
"portal.client.web/submit"]}
([value]
(submit {:encoding :edn} value))
([option value]
(client/submit (assoc option :port (get-port)) value)))