Skip to content

Commit 0c417ee

Browse files
christianalfonigitbook-bot
authored andcommitted
GitBook: [v23] one page modified
1 parent 8ec4cac commit 0c417ee

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

api-1/lazy.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,29 @@
33
You can lazy load configurations. You do this by giving each configuration a key with a function that returns the config when called. To actually load the configurations you can either call an effect or an action with the key of the configuration to load.
44

55
{% tabs %}
6-
{% tab title="overmind/index.ts" %}
6+
{% tab title="overmind/index.js" %}
77
```typescript
8-
import { IConfig } from 'overmind'
98
import { lazy } from 'overmind/config'
10-
import { Config as ModuleAConfig } from './moduleA'
119

1210
export const config = lazy({
13-
moduleA: async (): Promise<ModuleAConfig> => await import('./moduleA').config
11+
moduleA: async () => await import('./moduleA').config
1412
})
15-
16-
declare module 'overmind' {
17-
interface Config extends IConfig<typeof config> {}
18-
}
1913
```
2014
{% endtab %}
2115

22-
{% tab title="overmind/moduleA/index.ts" %}
16+
{% tab title="overmind/moduleA/index.js" %}
2317
```typescript
24-
import { IConfig } from 'overmind'
2518
import { state } from './state'
2619

2720
export const config = {
2821
state
2922
}
30-
31-
export interface Config extends IConfig<typeof config> {}
3223
```
3324
{% endtab %}
3425

35-
{% tab title="overmind/actions.ts" %}
26+
{% tab title="overmind/actions.js" %}
3627
```typescript
37-
import { AsyncAction } from 'overmind'
38-
39-
export const loadModule: AsyncAction = async ({ actions }) => {
28+
export const loadModule = async ({ actions }) => {
4029
await actions.lazy.loadConfig('moduleA')
4130
}
4231
```

0 commit comments

Comments
 (0)