juxt / clip

Light structure and support for dependency injection
MIT License
228 stars 15 forks source link

[Feature] Implement `clip/refs` or `clip/refset` to return all refs derived from a keyword #9

Closed kirillsalykin closed 4 years ago

kirillsalykin commented 4 years ago

Similar to https://github.com/weavejester/integrant#refs-vs-refsets

Currenlty ref returns only one thing, it would be nice to have ability to reference multiple things.

(clip/start
   {:components '{:foo1 {:start (constantly :foo1)}
                  :foo2 {:start (constantly :foo2)}
                  :foo3 {:start (constantly :foo3)}
                  :foob {:start (clip/refs :foo)}}})

So foob accepts [foo1 foo2 foo3] or maybe event better {:foo1 <resolved>, :foo2 <resolved> , :foo3 <resolved>}.

SevereOverfl0w commented 4 years ago

Why not build that up manually? Clip doesn't use keyword derivation, and being explicit about the used components seems useful.

What's the use-case?

kirillsalykin commented 4 years ago

The use case is next:

for instance there is an executor service (which executes actions) and there are several actions. Thus, the executor has actions as a dependency.

But probably indeed it is easier to have them added manually...

Thanks.

SevereOverfl0w commented 4 years ago

The reason I would encourage you to go manual is that refset creates a implicit link between things. The way it is written makes the link harder to see.

Besides, it falls apart when you have two executors.

It is annoying to duplicate, but I think the explicit flow is worth it in the long term.

kirillsalykin commented 4 years ago

I agree that explicit is better.

Thanks for the answer.