Hi Walter,

thanks for the quick reply.

Now, what does the other side of the call look like, where does the caller 
of "get-user" get the database component from? That's what I don't get.

Thanks,
Torsten.

Am Sonntag, 15. März 2015 16:51:51 UTC+1 schrieb Walter van der Laan:
>
> Hi,
>
> This is an example from http://github.com/stuartsierra/component
>
> (defn get-user [database username]
>   (execute-query (:connection database)
>     "SELECT * FROM users WHERE username = ?"
>     username))
>
>
> Here 'database' is a component which is passed to 'get-user' as an 
> argument. The component can be used just like any other hashmap, so 
> (:connection database) gets the database connection.
>
> On Sunday, March 15, 2015 at 4:20:35 PM UTC+1, Torsten Uhlmann wrote:
>>
>> Hi,
>>
>> I'm tapping my toes in component land and I think I lack some conceptual 
>> understanding, probably done too much OO.
>> Please forgive me if this is a stupid question (and I get a feel that it 
>> is)...
>>
>> Suppose I create a Lifecycle component with some state, say, a database 
>> component that creates a connection on calling "start". 
>> That connection is assoc'ed into the component map.
>>
>> Now, how do I access the database component map when I want to call 
>> functions that use the connection?
>> These functions are defined outside the defrecord of the component, how 
>> do they get access to the map?
>>
>> I could access the system var (the one that holds the system for 
>> development purposes) or save it into an atom, but I don't really think 
>> that would be a good approach?
>>
>> Thanks,
>> Torsten.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to