mirror of
https://github.com/sern-handler/website
synced 2026-06-06 01:16:47 +00:00
docs: ✨ Add some magic
This commit is contained in:
@@ -51,9 +51,13 @@ export default commandModule({
|
||||
## Safety
|
||||
- Services cannot be called in other services while makeDependencies is forming.
|
||||
- You will need to wire dependencies together.
|
||||
|
||||
|
||||
import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';
|
||||
|
||||
<Tabs>
|
||||
<TabItem>
|
||||
✅ A good example;
|
||||
```ts
|
||||
```ts title="index.ts" showLineNumbers
|
||||
// index.ts
|
||||
await makeDependencies(...pass you options here)
|
||||
```
|
||||
@@ -63,16 +67,18 @@ await makeDependencies(...pass you options here)
|
||||
import { Service } from '@sern/handler';
|
||||
const client = Service('@sern/client');
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem>
|
||||
❌ Don't do this
|
||||
```ts
|
||||
// index.ts
|
||||
```ts title="commands/ping.ts" showLineNumbers
|
||||
import { Service, makeDependencies } from '@sern/handler';
|
||||
/* DON'T USE SERVICES BEFORE CALLING makeDependencies */
|
||||
const logger = Service('@sern/logger');
|
||||
|
||||
await makeDependencies()
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
- Services can only be used after sern has made dependencies.
|
||||
- Calling a service before will crash your application.
|
||||
|
||||
Reference in New Issue
Block a user