clojure.browser.net/xpc-connection
function | since v0.0-927 | Edit |
(xpc-connection)
(xpc-connection config)
Source docstring:
When passed with a config hash-map, returns a parent
CrossPageChannel object. Keys in the config hash map are downcased
versions of the goog.net.xpc.CfgFields enum keys,
e.g. goog.net.xpc.CfgFields.PEER_URI becomes :peer_uri in the config
hash.
When passed with no args, creates a child CrossPageChannel object,
and the config is automatically taken from the URL param 'xpc', as
per the CrossPageChannel API.
(defn xpc-connection
([]
(when-let [config (.getParameterValue
(Uri. (.-href (.-location js/window)))
"xpc")]
(CrossPageChannel. (gjson/parse config))))
([config]
(CrossPageChannel.
(reduce (fn [sum [k v]]
(if-let [field (get xpc-config-fields k)]
(doto sum (gobj/set field v))
sum))
(js-obj)
config))))