Skip to content

Commit 5b080b6

Browse files
committed
Improve dependency injection docs
1 parent 84d7620 commit 5b080b6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • apps/web/src/app/(docs)/docs/dependency-injection

apps/web/src/app/(docs)/docs/dependency-injection/page.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export interface TimeDep {
177177
}
178178

179179
export interface LoggerDep {
180-
logger: Logger;
180+
readonly logger: Logger;
181181
}
182182

183183
const app = (deps: TimeDep & LoggerDep) => {
@@ -250,7 +250,7 @@ app(appDeps);
250250

251251
- Start with an interface or type—everything can be a dependency.
252252
- To avoid clashes, wrap dependencies (`TimeDep`, `LoggerDep`).
253-
- Write factory function (`createTime`, `createTestTime`)
253+
- Write factory functions (`createTime`, `createTestTime`)
254254
- Both regular functions and factory functions accept a single argument named `deps`, combining one or more dependencies (e.g., `A & B & C`).
255255
- Sort dependencies alphabetically in ascending order when combining them.
256256

@@ -369,7 +369,7 @@ const result = timeUntilEvent(deps)(1742329310767);
369369
- `eventTimestamp` is just a number—it's not a dependency because it’s local to the function’s logic.
370370
- `time` is a dependency because it interacts with the outside world (`Date.now()`).
371371

372-
**Key takeaway**: Use dependencies for external interactions (I/O, side effects) and keep regular arguments for pure, local data. At the composition root, assemble your `deps` object once and pass it where needed—over-providing is fine, as shown in the Example (#example) section!
372+
**Key takeaway**: Use dependencies for external interactions (I/O, side effects) and keep regular arguments for pure, local data. At the composition root, assemble your `deps` object once and pass it where needed—over-providing is fine, as shown in the [Example](#example) section.
373373

374374
**Why shouldn't dependencies use generic arguments?**
375375

0 commit comments

Comments
 (0)