All Downloads are FREE. Search and download functionalities are using the official Maven repository.

meyvn.nrepl_middleware.portal.clj Maven / Gradle / Ivy

The newest version!
(ns meyvn.nrepl-middleware.portal
  (:require [portal.api :as p]
            [portal.viewer :as v]))

(def portal (atom {}))

(def defaults
  {string? v/text
   bytes?  v/bin})

(defn- get-viewer-f [value]
  (or (some (fn [[predicate viewer]]
              (when (predicate value)
                viewer))
            defaults)
      v/inspector))

(defn submit [value]
  (let [f (get-viewer-f value)]
    (p/submit (f value))))

(defn message []
  (if (instance? portal.runtime.jvm.client.Portal @portal)
    "Portal started"
    "Portal stopped"))

(defn toggle []
  (if (seq @portal)
    (do (p/close)
        (remove-tap #'submit)
        (reset! portal {})
        (message))
    (do
      (reset! portal (p/open {:portal.colors/theme :portal.colors/solarized-light}))
      (add-tap #'p/submit)
      (message))))





© 2015 - 2024 Weber Informatics LLC | Privacy Policy