Code Monkey home page Code Monkey logo

repload's Introduction

repload

A Clojure utility function to reload all referred vars and aliased namespaces in a REPL.

Motivation

  1. Restarting the REPL is stupid
  2. Manually :reloading referred vars and aliases is a pain
  3. tools.namespace has too much overhead (e.g. state management)

Install

"Leiningen version"

repload was designed to be used in the REPL exclusively. If you are using Leiningen (which you should), you can inject repload into your profiles.clj to make it available in all your REPLs.

Edit your ~/.lein/profiles.clj file:

{:user
 {
   ; ...
   :dependencies [ ; ...
                   [john2x/repload "0.0.3"]]
   :injections   [ ; ...
                   (require 'repload)
                   (require '[repload :refer [repload]])]
  }
 }

Usage

Now open up a new REPL:

$ lein new myproject
$ lein repl

user=> (use 'myproject.core)
nil
user=> (require '[myproject.core :as mp])
nil
user=> (source foo)
(defn foo
  "I don't do a whole lot."
  [x]
  (println x "Hello, World!"))
nil
user=> (foo "test")
test Hello, World!
nil
user=> (mp/foo "test")
test Hello, World!
nil

;; make some changes to your project

user=> (repload)
Reloading myproject.core [foo]
Reloading myproject.core with alias mp
nil
user=> (source foo)
(defn foo
  "I don't do a whole lot."
  [x]
  (println x "Goodbye, World!"))
nil
user=> (foo "test")
test Goodbye, World!
nil
user=> (mp/foo "test")
test Goodbye, World!
nil

By default, repload excludes reloading namespaces starting with clojure and repload. You can override these prefixes with the following:

;; add "myproject" as an ignored prefix
user=> (repload/add-exclude-prefix! "myproject")
user=> (repload)
nil  ;; nothing reloaded

;; set "myproject" as the *only* ignored prefix
;; (causing a *lot* of `clojure.core` vars to be reloaded)
;; (*not recommended*)
user=> (repload/set-exclude-prefixes! ["myproject"])

License

Copyright © 2014 John Louis Del Rosario

Distributed under the MIT license.

repload's People

Contributors

john2x avatar

Stargazers

Brian Maddy avatar Andrew Kirilenko avatar  avatar Cole Willsea avatar Mohammad Sadegh Khoeini avatar Dom Kiva Meyer avatar Alan Dipert avatar Ivan Pierre avatar Benedikt Terhechte avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.