Hi - I've been playing with this and I'm a little confused.
I can understand how you use the library to pass around stateful
components, and to start/stop them and wire them up etc.
But I'm not sure I see how it should be used for more general dependency
injection.
I'll pick a concrete example - in the readme you have an ExampleComponent
which calls "(get-user database :admin)"
the "get-user" function then gets the connection from the Database
component - but it's still coupled to the particular implementation of
"execute-query":
(defn get-user [database username]
(execute-query (:connection database)
"SELECT * FROM users WHERE username = ?"
username))
If you wanted to unit test this function, you could pass whatever database
connection thing you'd like - but you couldn't stub out the whole database,
as execute-query is still coupled to the implementation of your database.
More generally, anything that calls "get-user" will need to provide some
sort of working database, or mock/stub out the call to execute-query, or
the call to get-user itself.
Is there something I'm missing? Is there some way you could/would do this
with the component library? Or is this not the point of the library?
- Korny
On 21 November 2013 02:01, Stuart Sierra <[email protected]>wrote:
> This is a small library/framework I've been working on for a few months.
>
> https://github.com/stuartsierra/component
>
> I use this to manage runtime state in combination with my "reloaded"
> workflow using tools.namespace.[1]
>
> I've started using this on some personal and professional projects and it
> seems to be working fairly well.
>
>
> [1]: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Kornelis Sietsma korny at my surname dot com http://korny.info
.fnord { display: none !important; }
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.