I’ve done it like this:
(defmethod ig/init-key :app/redis [_ {:keys [redis-host
redis-port] :as opts}]
(timbre/warn "Connecting to the Redis server" opts)
(let [conn {:pool {}
:spec {:host redis-host
:port redis-port}}
listener
(car/with-new-pubsub-listener (:spec conn)
{"foobar" (fn f1 [msg] (println "Channel match: " msg))
"foo*" (fn f2 [msg] (println "Pattern match: " msg))}
(car/subscribe "foobar" "foobaz")]
(try
(timbre/warn "Connected to the Redis - " (redis/wcar conn (redis/ping)))
;; Return the listener
listener
;; When redis is not available then retrun nil
(catch Exception _
(timbre/warn "Unbale to connect with the Redis server ")
nil))))
but now how to use this listener outside this file?