Fork me on GitHub
#integrant
<
2023-12-29
>
Joseph Graham16:12:29

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?

delaguardo18:12:07

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.

Joseph Graham18:12:34

But that system object would only be available in my user namespace?

delaguardo18:12:05

yes, is it a problem?

Joseph Graham18:12:45

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.

delaguardo18:12:57

other way around, require handler's ns in the namespace where you define your dev system and exec functions from there

delaguardo18:12:47

also I usually move what I end up in the comment form into a separate test namespace as a final dev step.

Joseph Graham18:12:45

OK I'll try to refactor it after dinner and see what I can figure out.

Joseph Graham05:12:07

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.

Joseph Graham05:12:56

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?

pavlosmelissinos11:12:48

Why do you need a system atom?

Joseph Graham11:12:34

Honestly I was trying to copy what they did in kit framework.

Joseph Graham11:12:01

But I have spent the past four hours refactoring everything to not use an atom.

delaguardo11:12:29

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.

pavlosmelissinos11:12:15

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.