ts-ioc-container 50.2.4 → 50.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ provider pipelines, aliases, and custom injector strategies.
|
|
|
47
47
|
- [Alias](#alias) `asAlias`
|
|
48
48
|
- [Decorator](#decorator) `decorate`
|
|
49
49
|
- [Registration](#registration) `@register`
|
|
50
|
-
- [Key](#key) `
|
|
50
|
+
- [Key](#key) `bindTo`
|
|
51
51
|
- [Scope](#scope) `scope`
|
|
52
52
|
- [Module](#module)
|
|
53
53
|
- [Hook](#hook) `@hook`
|
|
@@ -126,8 +126,8 @@ describe('Quickstart', function () {
|
|
|
126
126
|
## Cheatsheet
|
|
127
127
|
|
|
128
128
|
- Register class with key (preferred): `@register(bindTo('Key')) class Service {}` then `container.addRegistration(R.fromClass(Service))`
|
|
129
|
-
- Register value: `R.fromValue(config).
|
|
130
|
-
- Register factory: `R.fromFn((c) => createX(c)).
|
|
129
|
+
- Register value: `R.fromValue(config).bindTo('Config')`
|
|
130
|
+
- Register factory: `R.fromFn((c) => createX(c)).bindTo('X')`
|
|
131
131
|
- Singleton: `@register(singleton())`
|
|
132
132
|
- Scoped registration: `@register(scope((s) => s.hasTag('request')))`
|
|
133
133
|
- Resolve by alias: `container.resolveByAlias('Alias')`
|
|
@@ -138,9 +138,9 @@ describe('Quickstart', function () {
|
|
|
138
138
|
|
|
139
139
|
> [!TIP]
|
|
140
140
|
> For classes, prefer the `@register(bindTo('Key'))` decorator over the fluent
|
|
141
|
-
> `R.fromClass(Class).
|
|
141
|
+
> `R.fromClass(Class).bindTo('Key')` chain. The decorator co-locates the binding
|
|
142
142
|
> with the class and reads consistently with other registration pipes
|
|
143
|
-
> (`scope`, `singleton`, `appendArgsFn`, ...). Use the fluent `
|
|
143
|
+
> (`scope`, `singleton`, `appendArgsFn`, ...). Use the fluent `bindTo` chain only
|
|
144
144
|
> for `R.fromValue(...)` and `R.fromFn(...)` (which have no class to decorate)
|
|
145
145
|
> or for third-party classes you don't own.
|
|
146
146
|
|
|
@@ -1285,7 +1285,7 @@ Provider is dependency factory which creates dependency.
|
|
|
1285
1285
|
|
|
1286
1286
|
- `Provider.fromClass(Logger)`
|
|
1287
1287
|
- `Provider.fromValue(logger)`
|
|
1288
|
-
- `new Provider((container,
|
|
1288
|
+
- `new Provider((container, options) => container.resolve(Logger, options))`
|
|
1289
1289
|
|
|
1290
1290
|
```typescript
|
|
1291
1291
|
import {
|
|
@@ -2140,11 +2140,11 @@ describe('Decorator Pattern', () => {
|
|
|
2140
2140
|
|
|
2141
2141
|
Registration is provider factory which registers provider in container.
|
|
2142
2142
|
|
|
2143
|
-
- `@register(
|
|
2144
|
-
- `Registration.fromClass(Logger).
|
|
2143
|
+
- `@register(bindTo('logger'))`
|
|
2144
|
+
- `Registration.fromClass(Logger).bindTo('logger')`
|
|
2145
2145
|
- `Registration.fromClass(Logger)`
|
|
2146
2146
|
- `Registration.fromValue(Logger)`
|
|
2147
|
-
- `Registration.fromFn((container,
|
|
2147
|
+
- `Registration.fromFn((container, options) => container.resolve(Logger, options))`
|
|
2148
2148
|
|
|
2149
2149
|
### Key
|
|
2150
2150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "50.2.
|
|
3
|
+
"version": "50.2.5",
|
|
4
4
|
"description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"docs"
|