weavejester/integrant-repl

`prep` does not work

hin522 opened this issue ยท 4 comments

The prep function does not call the method defmethod ig/prep-key. An example below shows using integrant.core/prep works as expected whereas using integrant.repl/prep does not.

(def config {:greeting "Hello world"})

(defmethod ig/prep-key :greeting [_ opts]
  "Hello world new")

(defmethod ig/init-key :greeting [_ opts]
  (prn opts))

Use integrant

(require '[integrant.core :as ig])
(-> config
    ig/prep
    ig/init)

=> "Hello world new"

Use integrant.repl

(require '[integrant.repl :refer [prep init]])
(integrant.repl/set-prep! (constantly config))
(prep)
(init)

=> "Hello world"

The README Integrant-REPL needs to be updated, as it pre-dates the introduction of the ig/prep function. The set-prep! function should now include ig/prep:

(integrant.repl/set-prep! #(ig/prep config))

I'll update the README tonight or tomorrow.

Thanks, it works as expected.

@weavejester Sorry for being annoying, but your "tonight or tomorrow" still did not happen yet ๐Ÿ˜… It took me 1 hour to figure the same issue out by myself.

@Joeyjoejoe #24 seems good to me. Thank you.

Fixed (at last!)