-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to bind a specific instance of a singleton #23
Comments
Wow i actually somehow haven't thought of this use case. Thank you for bringing it to my attention. I'm not sure that the binding builders should have control over the scope of bindings. That's more the responsibility of the scope configurators. I think using a default factory is the best approach here. That way, no Anyway, it should be possible to make the I won't be able to do this in a while because I'm currently on vacation nowhere near my computer but i'm glad to help you with it. Just ask if you have any questions |
Thanks for the feedback! You would know best, but it seems like Anyways, I got started on a branch here: https://github.com/TechnoPorg/Syrette/tree/factory-no-nightly |
Oh i didn't think about that. It should be possible to make it not take a reference and instead have |
First, @HampusMat Thanks for making this library! I think it has a lot of potential. InversifyJS (since README indicate inspiration from InversifyJS), has a feature to bind constant. It would be very useful to have that implemented. |
It should be possible relatively soon but i think i want to also complete #24 because then #11 should be doable as well as i had some trouble with the nested functions while trying to implement that. These changes would make the factory API stable & unchanging. I'm not sure though as that will make the the release delayed quite a bit |
No nevermind about #11 that can wait so at least #24 and #25. Max two weeks though i can't promise anything |
Should i add a |
I think that a |
Right. That's reasonable. I can add it if anyone asks for it in the future but with a name that signifies that it clones the value |
Hi! I'm loving this crate so far, so thank you for all your hard work. There's one thing which it seems to be missing to fit my use case, though:
It would be nice to be able to bind a type to an existing singleton, like so:
Otherwise, we either have to use the
factory
feature, which forces rust nightly, or depend solely on the dependency'snew
function, which would make it quite challenging to configure the service based on external information.There's a tentative PoC here: https://github.com/TechnoPorg/Syrette/tree/explicit-singleton-binding/. But I'm not especially familiar with Syrette, so I'm sure there's much there that I left out. For one thing, the
injectable
derive macro still requires anew
constructor on my branch, even though it technically isn't needed.Thanks!
The text was updated successfully, but these errors were encountered: