Async lifecycles in DI #115
Replies: 2 comments 3 replies
-
This sounds like a good idea. We would need to evaluate the consequences of that and decide base on that. I would be particularly interested whether this is:
|
Beta Was this translation helpful? Give feedback.
-
Looking at it right now, We'd probably want to introduce our own
The complexity of this is largely in the implementation within our DI's resolving algorithm and lifecycle-management:
All of this is additive behaviour - if the end-user doesn't implement either interface, there's no change in behaviour. If the user has a type which already implements |
Beta Was this translation helpful? Give feedback.
-
Working through how we adapt to xunit, encountering it's
IAsyncLifecycle
I realised we could be offering asynchronous lifecycles for objects managed in BoDi - essentially supportingIAsyncDisposable
and some kind ofIAsyncInitializable
interface. We'd need to make the Resolve mechanism ResolveAsync, but the value would be that users get their whole async lifecycle handled for them - when a dependency is resolved it's already initialized and when it's container falls out of scope it gets cleaned up asynchronously.If we could combine this with something like declarative lifetimes, it could significantly reduce the need for test-run-, feature- and scenario-level hooks.
Beta Was this translation helpful? Give feedback.
All reactions