integrant-repl

repository·master·Indexed 41 days ago

https://github.com/weavejester/integrant-repl

A Clojure library implementing the 'reloaded workflow' for Integrant, allowing developers to reload source code and restart Integrant systems within a REPL session. Version 0.5.1 provides functions like prep, init, go, halt, and reset to manage the system lifecycle.

Tokens
603
Snippets
4
Records
4
Agent score
2%

What's inside integrant-repl

  1. Manage the Integrant system lifecycle in the REPL

    master

    Once set-prep! is configured, use the following functions to control your system:

    • (prep): Prepares the configuration. The result is stored in integrant.repl.state/config.
    • (init): Initiates the configuration into a running system. The system is stored in integrant.repl.state/system.
    • (go): A convenience function that performs both (prep) and (init) in one step.
    • (halt): Stops the running system.
    • (reset): Reloads source files and restarts the system.
    • (reset-all): Resets everything (including clearing state).
    user=> (go)
    :initiated
    
    user=> (halt)
    :halted
    
    user=> (reset)
    :reloading (...)
    :resumed
  2. Configure and use integrant-repl

    master

    To use integrant-repl, require the integrant.repl namespace in your user.clj and define a zero-argument function using set-prep! that returns a prepared Integrant configuration.

    This setup allows you to manage the lifecycle of your Integrant system (preparing, initiating, halting, and resetting) directly from the REPL.

    (ns user
      (:require [integrant.core :as ig]
                [integrant.repl :refer [clear go halt prep init reset reset-all]]))
    
    (def config {::foo {:example? true}})
    
    (integrant.repl/set-prep! #(ig/expand config (ig/deprofile [:dev])))
  3. Configure file monitoring for reloading

    master

    By default, integrant-repl monitors all local directories on the classpath for changes to files ending in .clj, .cljc, or .cljs.

    You can customize this behavior using set-reload-options!. Use this to specify specific directories to watch or to change the file pattern used for matching.

    user=> (set-reload-options! {:dirs ["src/clj"], :file-pattern #"\.clj"})
    {:since 1757694521568, :files {}, :namespaces {}}