integrant

Joseph Graham 2023-12-29T16:41:29.313339Z

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?

pavlosmelissinos 2023-12-30T11:00:48.251189Z

Why do you need a system atom?

Joseph Graham 2023-12-30T11:01:34.205349Z

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

Joseph Graham 2023-12-30T11:02:01.859369Z

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

Kirill Chernyshov 2023-12-30T11:02:29.231619Z

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.

pavlosmelissinos 2023-12-30T11:17:15.870389Z

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.

Kirill Chernyshov 2023-12-29T18:05:07.397789Z

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 Graham 2023-12-29T18:07:34.050939Z

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

Kirill Chernyshov 2023-12-29T18:10:05.709519Z

yes, is it a problem?

Joseph Graham 2023-12-29T18:13:45.173829Z

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.

Kirill Chernyshov 2023-12-29T18:18:57.905059Z

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

Kirill Chernyshov 2023-12-29T18:20:47.912639Z

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

Joseph Graham 2023-12-29T18:22:45.224989Z

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

Joseph Graham 2023-12-29T18:23:00.445479Z

And thanks!

Joseph Graham 2023-12-30T05:36:07.786709Z

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 Graham 2023-12-30T05:43:56.075599Z

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?