-
Notifications
You must be signed in to change notification settings - Fork 724
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
Bind/inject a promise, not the value the promise resolves to. #1482
Comments
As a workaround, could you construct an object which contains the promise? I haven't used Inversify in a while so YMMV |
I did think about that, but there would be about 6,000 changes across 2500 files. And we would have to delicately identify which ones are async and which ones are not to change to destructuring |
Hey @WORMSS, just to clarify your issue, you are converting from some other DI system which has a If so, I'd be interested in putting a solution together for this. I feel like we could add a parameter to @PodaruDragos @dcavanagh @inversify/maintainers welcome any thoughts before I make the PR. ty. |
That would be a great solution, since it's at the container level, that way we can even have both systems working independently. This will make our migration much simpler as we transition to the full power of inversify. I just thought, this is doubly convenient because we can use our abstraction layer to bind to both containers simultaneously but our current (soon to be legacy) resolver can retrieve ONLY from the lacks |
We were able to bind a |
Added to milestone |
That will be great. We actually paused our migration completely and "ONLY" use direct container.get() and nothing is using class providers yet. Thank you for keeping this on the back burner getting us to this point. |
The behavior is the expected one. To solve the issues you're experiencing in your example, rely on |
I want to inject a promise, not the value the promise resolves to.
Expected Behavior
Current Behavior
_getButThrowIfAsync
throws an error.You are attempting to construct '" + key + "' in a synchronous way\n but it has asynchronous dependencies.
But, I don't want the Value the Promise returns.. I want THE PROMISE itself. The promise IS the value.
Possible Solution
a
container.get()
that bypasses_getButThrowIfAsync
and gets the exact thing I want.Steps to Reproduce (for bugs)
I have optionally commented out the types and a bunch of other boilerplate, but you get the idea.
Context
We are midway through the process of changing over everything to 'real' inversify with actual injection from constructors and stuff,
but it's a big codebase and we are nowhere near finished, but we wanted to start getting things setup and ready, and doing our best to use it with vue3 composibles.
but we found that this "throwing if it's a promise" is slowing us down in our interim because we need to keep switching between get and getAsync when it really isn't needed at this point.
We kind of need a
container.get_Even_If_Its_A_Promise_I_Dont_Care(key)
function. So everything can go through a single call on the container.Your Environment
Stack trace
The text was updated successfully, but these errors were encountered: