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

Update README.md #33

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Instead, you have the "same key, same bean" rule:

> If two beans of the same *key* are injected by the same component, then they are the same bean instance.

This means a component contains at most one instance per bean class (unless of course you're using qualifiers).
Intuitively this means a component injects the same bean instance everywhere (unless of course you're using qualifiers or inject a provider).

If you want to re-use a bean across multiple components, use a `@Factory` or a `@Builder` to pass it.
If you want to re-use a bean across multiple components, or multiple instances of the same component, use a `@Factory` or a `@Builder` to pass it.
If possible, the component will use instance that was passed this way, rather than create a new bean instance.

If you inject `Provider<TheBean>`, rather than `TheBean` directly, calling `provider.get()` will create a fresh bean instance every time.
Expand Down
Loading