-
Notifications
You must be signed in to change notification settings - Fork 713
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
Async @postConstruct/onActivation + @preDestroy/onDeactivation #1086
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…c/async, prevent onActivation from firing until lazy value is available
…eeded test interfaces
…e than once (even though it is a singleton). removed support for onActivation and context access in order to keep internal code simple. in theory, the async call can happen at any time (or in-side multiple contexts), so conceptually we should not support access the current context
…sync support for @PostConstruct, unbind/unbindAll async APIs, onDeactivation support
…r level (post-binding), update Lazy to account for the potential of nested Lazy objects
…yet (for example, when using auto bind)
…apshotting, support traversing container tree for onActivations, fix onACtivation when depedency is Lazy, updated tests to use approriate equals handler
11 tasks
…eir may be a new way to to approach the async branch now that instantiation.ts can inspect constructor args for lazy
11 tasks
closing and continuing with #1132 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For anyone wanting to play around with this, you can use the NPM release:
@parisholley/inversify-async:1.0.20
In continuation of #1074, allowing async hooks into dependency lifecycles.
Description
Global onActivation
Binding onActivation
Parent/Child onActivation
Module onActivation
Related Issue
#551
#1074
#471
Motivation and Context
For testing (or perhaps a custom request based framework where child containers are created for each web request to implement "Request Scope" similar to spring), it may be useful to have async construct/destroy methods. For example, a web request where we want to run all service calls in a transaction and commit on at the end (by unbinding the container), or in tests by rolling back database changes for more performant runs.
How Has This Been Tested?
Similar to test cases for #1074, ensure that errors are thrown when mixing sync and async APIs.
Types of changes
Checklist: