Fork me on GitHub
#yada
<
2015-11-27
>
nha11:11:46

Hello, I am trying to inject component dependencies into bidi routes. My RouteProvider function is never called, I am not sure how I am supposed to use it. Here are my attempts, I would appreciate any help : https://www.refheap.com/112132

tangrammer12:11:00

Hi @nha did you realise that you have to pass the component that behaves as a RouteProvider to a proper component modular.bidi/Router? https://github.com/juxt/chatserver/blob/18a0671d8678a8a02eac6f53119a1cff7469f1d1/src/chatserver/system.clj#L99-L101

nha13:11:37

@tangrammer: Ah not at all thanks. This is why my route fn was not called then. I will dig into that, thanks simple_smile

malcolmsparks14:11:29

@nha: @tangrammer is right, RouteProvider is really a marker protocol you can use to build your own component-based router, or use the one in modular.bidi for an idea

malcolmsparks14:11:55

most people hijack the Ring request for dependency injection, I think that's a bit of a hacky solution

malcolmsparks14:11:18

I prefer to inject dependencies the idiomatic way that Stuart Sierra suggests