weavejester / integrant-repl

Reloaded workflow functions for Integrant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integrant-REPL

A Clojure library that implements the user functions of Stuart Sierra's reloaded workflow for Integrant.

It's very similar to reloaded.repl, except that it works for Integrant, rather than Component.

Install

Add the following dependency to your dev profile:

[integrant/repl "0.3.3"]

Usage

Require the integrant.repl namespace in your user.clj file, and use the set-prep! function to define a zero-argument function that returns a prepped Integrant configuration.

For example:

(ns user
  (:require [integrant.core :as ig]
            [integrant.repl :refer [clear go halt prep init reset reset-all]]))

(integrant.repl/set-prep! #(ig/prep {::foo {:example? true}}))

To prepare the configuration, you can now use:

user=> (prep)
:prepped

The configuration is stored in integrant.repl.state/config. To initiate the configuration, use:

user=> (init)
:initiated

This will turn the configuration into a running system, which is stored in integrant.repl.state/system.

Because these two steps are common, we can instead use:

user=> (go)
:initiated

This performs the (prep) and (init) steps together. Once the system is running, we can stop it at any time:

user=> (halt)
:halted

If we want to reload our source files and restart the system, we can use:

user=> (reset)
:reloading (...)
:resumed

Behind the scenes, Integrant-REPL uses tools.namespace. You can set the directories that are monitored for changed files by using the refresh-dirs function:

user=> (require '[clojure.tools.namespace.repl :refer [set-refresh-dirs]])
nil
user=> (set-refresh-dirs "src/clj")
("src/clj")

License

Copyright © 2023 James Reeves

Released under the MIT license.

About

Reloaded workflow functions for Integrant

License:MIT License


Languages

Language:Clojure 100.0%