Skip to content
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 scoped providers #32

Open
TehPers opened this issue May 13, 2021 · 0 comments
Open

Add scoped providers #32

TehPers opened this issue May 13, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@TehPers
Copy link
Owner

TehPers commented May 13, 2021

Add a way for providers to have a scope. For example, one way a scope might be implemented is this:

let scope = injector.scope(); // has Drop impl
let foo: Svc<Foo> = scope.get().unwrap();

Scoped providers don't guarantee the lifetime of the values that they provide. If a scope is dropped, there's no way to know if all references to the services it provided were dropped since they use reference-counted pointers or have been moved to outside of the injector (in the case of owned injection). Instead, scopes only would guarantee that scoped providers provide the same instances from the same scope, and different instances from different scopes.

@TehPers TehPers added the enhancement New feature or request label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant