Closed pauleveritt closed 5 years ago
the Injector is just a service factory and the factory api is (container)
right now - I can't accept this on its own as it's nonsensical in the current state of the rest of the library
Hmm, ok. Should I have Props as a singleton and stash it in the container?
I mean I don't know what you're using it for so I can't answer that. I just know whatever it is doesn't work in its current form.
If you wrote an integration test you'd see - it only works cuz it's testing against your dummy objects.
How I'm using it: in a Jinja2 template you do {{ Breadcrumb(label='Home', href='/') }} and a Breadcrumb is looked up, with those two values passed into its construction, which might get other fields from DI.
I can't really put those values in the container, as there are lots of of these getting created per request.
The injector isn't a public api but it sounds like you're using it as such somehow. You'd have to paste a more complete example that actually uses wired.
The code I have right now might be kind of hard to sort out the indirections. If you're ok with it, I'll push and give some explanations. Or, I can extract it into some standalone case, maybe.
Of course you might have a spasm seeing my indirections and give me a far better path. I struggled with it, not happy with where I'm at.
On its face this is a simple change, but it's directly competing with some other ideas I've been thinking about which would allow passing in props per-instance to the factory. This change to the injector doesn't change anything publicly in wired and thus doesn't serve a purpose to me. I think you should just vendor the injector if you're using it - in my mind the injector exists solely to work as a factory in wired and thus should support the minimal functionality that wired needs. If I change how passing props to factories works, I don't want this feature here to make that more difficult to support.
For wired_components, allow passed in "props". If this looks ok, and the docs cleanup is merged, I'll then add docs for this.