Skip to content

Commit 8bdb0d8

Browse files
committed
Update readme
1 parent b481801 commit 8bdb0d8

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

readme.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class UserService:
4646
def __init__(self, db: Database) -> None:
4747
self.db = db
4848

49-
# Now that the dependencies are defined, register them with the container.
50-
# You can pass a list of classes, functions, or even modules to be scanned.
5149
container = create_sync_container(injectables=[Database, UserService])
5250
user_service = container.get(UserService) # ✅ Dependencies resolved.
5351
```
@@ -118,6 +116,27 @@ container = create_sync_container(injectables=[make_settings, make_database])
118116
database = container.get(Database) # ✅ Dependencies resolved.
119117
```
120118

119+
**4. Scale**
120+
121+
No need to list every injectable manually. Scan entire packages to register all at once.
122+
123+
```python
124+
import wireup
125+
import app
126+
127+
container = wireup.create_sync_container(
128+
# Classes and functions decorated with @injectable in these
129+
# packages or modules are registered and ready to use.
130+
injectables=[
131+
app.services,
132+
app.repositories,
133+
app.factories
134+
]
135+
)
136+
137+
user_service = container.get(UserService) # ✅ Dependencies resolved.
138+
```
139+
121140
### 🎯 Function Injection
122141

123142
Inject dependencies directly into functions with a simple decorator.
@@ -131,7 +150,7 @@ def process_users(service: Injected[UserService]):
131150

132151
### 📝 Interfaces & Abstractions
133152

134-
Define abstract types and have the container automatically inject the implementation.
153+
Depend on abstractions, not implementations. Bind implementations to interfaces using Protocols or ABCs.
135154

136155
```python
137156
from wireup import injectable, create_sync_container
@@ -297,10 +316,10 @@ graph LR
297316
Worker[Celery / Worker]
298317
end
299318
300-
API -->|Injects| Services
301-
CLI -->|Injects| Services
302-
Worker -->|Injects| Services
303-
319+
API -->|Uses| Services
320+
CLI -->|Uses| Services
321+
Worker -->|Uses| Services
322+
304323
Services --> Domain
305324
```
306325

0 commit comments

Comments
 (0)