This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-29
Channels
- # aleph (1)
- # announcements (5)
- # beginners (21)
- # cider (4)
- # clojars (1)
- # clojure (39)
- # clojure-europe (5)
- # clojure-norway (133)
- # clojurescript (5)
- # datomic (27)
- # exercism (2)
- # gratitude (4)
- # humbleui (21)
- # hyperfiddle (10)
- # integrant (16)
- # introduce-yourself (1)
- # lsp (17)
- # matrix (1)
- # nbb (10)
- # overtone (5)
- # polylith (21)
- # re-frame (6)
- # squint (3)
- # tools-deps (22)
- # yamlscript (102)
Hi all. I am learning Integrant and am a bit puzzled how it works with interactive development. Lets say my handler requires a database connection. So I use Integrant to create a closure over that. The problem is now that I can't do interactive development with my handler or db queries since they can only work when Integrant uses them?
imho, the best way is to include integrant system into your interactive workflow. for example using integrant-repl will give you always up to date system from which you can get prepped and initiated handler.
But that system object would only be available in my user namespace?
yes, is it a problem?
So the idea is: to require in my handler namespace to user namespace, then run my functions? It means I have to type in the repl rather than using rich comments.
other way around, require handler's ns in the namespace where you define your dev system and exec functions from there
also I usually move what I end up in the comment form into a separate test namespace as a final dev step.
OK I'll try to refactor it after dinner and see what I can figure out.
And thanks!
What is actually the benefit of integrant-repl over just evaluating (-main)
from a rich comment? It seems to cause more problems than it solves since my system map ends up in integrant.repl.state/config
instead of the atom where I normally put it.
Easiest solution would be to just put my system atom in a separate namespace so everything can require and access it. But I guess this is considered bad practice?
Why do you need a system atom?
Honestly I was trying to copy what they did in kit framework.
But I have spent the past four hours refactoring everything to not use an atom.
integrant-repl solves the problem of reloading your code so you don't have to manually eval every namespace that depends on the one you just change.
Might not be the standard way of doing things but I'm only using integrant to do the initialization of the system map. After that, I'm responsible for passing it around wherever it needs to be used (no atoms anywhere). I'm making the assumption that the system map won't change while the system is running but it has worked well so far with the benefit of not introducing side-effects into the system. If I need to change something in the system I just ig/reset and integrant takes care of reloading everything based on the dependencies I have specified in the system config.