-
-
Notifications
You must be signed in to change notification settings - Fork 284
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
fix(di): move locals arg to DIInvokeOptions #2890
Changes from all commits
666a12a
f4fa686
1e94a01
f7fa7d9
18ce1e2
0a20009
c157178
9e07d6e
ec6971d
f4af794
5eeabba
c13437a
3ae2919
fb3288f
b9484d0
ab1e239
aa6fd67
e25e54f
243bdce
f581b44
5d9bfda
61f1640
fc71af0
857ea09
51aba80
ef4b43a
4c9c32f
6acfaeb
501ac71
d731171
edd143d
e2a2e85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
The scope of a [Provider](/docs/providers.md) defines the lifecycle and visibility of that bean in the context in which it is used. | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
Ts.ED DI defines 3 types of @@Scope@@ which can be used on injectable classes: | ||||||||||||||||||||||||||||||
Ts.ED DI defines 3 types of @@ProviderScope@@ which can be used on injectable classes: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
- `singleton`: The default scope. The provider is created during server initialization and is shared across all requests. | ||||||||||||||||||||||||||||||
- `request`: A new instance of the provider is created for each incoming request. | ||||||||||||||||||||||||||||||
|
@@ -75,9 +75,7 @@ Instance scope used on a provider tells the injector to create a new instance ea | |||||||||||||||||||||||||||||
With the functional API, you can also rebuild any service on the fly by calling @@inject@@ with the `rebuild` flag: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
```typescript | ||||||||||||||||||||||||||||||
import {inject, injector} from "@tsed/di"; | ||||||||||||||||||||||||||||||
import {inject} from "@tsed/di"; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
const myService = inject(MyService, {rebuild: true}); | ||||||||||||||||||||||||||||||
// similar to | ||||||||||||||||||||||||||||||
const myService2 = injector().invoke(MyService, {rebuild: true}); | ||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||
Comment on lines
+78
to
81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) LGTM! Consider adding usage guidance for the rebuild flag. The simplified import and example are clear and accurate. However, it would be helpful to add a brief explanation of when developers should consider using the Consider adding context like: import {inject} from "@tsed/di";
const myService = inject(MyService, {rebuild: true});
+
+// The rebuild flag is useful when you need to:
+// - Force creation of a new instance regardless of scope
+// - Reset the state of a service
+// Note: Use with caution as it bypasses the normal scoping rules 📝 Committable suggestion
Suggested change
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Consider adding usage guidance for the rebuild flag.
While the code example is clear, it would be helpful to add a brief explanation of when developers should use the
rebuild
flag versus regular injection. This would help prevent misuse and potential performance issues.Consider adding a note like this:
📝 Committable suggestion