Skip to content

Commit cc1d433

Browse files
authored
Use new writable and callable in docs
1 parent f304696 commit cc1d433

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

docs/api/create-router-controls.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,37 @@ Create controls:
2525
// @/shared/routing
2626
import { createRouterControls } from 'atomic-router';
2727

28-
export const controls = createRouterControls()
28+
export const controls = createRouterControls();
2929

30-
controls.$query // Store<RouteQuery> Store with current query params
31-
controls.back // Event<void> Trigger it to call history.back
32-
controls.forward // Event<void> Trigger it to call history.forward
30+
controls.$query; // StoreWritable<RouteQuery> Store with current query params
31+
controls.back; // EventCallable<void> Trigger it to call history.back
32+
controls.forward; // EventCallable<void> Trigger it to call history.forward
3333
```
3434

3535
Pass it to `createHistoryRouter`:
3636
```ts
3737
// @/app/router
38-
import { createHistoryRouter } from 'atomic-router'
38+
import { createHistoryRouter } from 'atomic-router';
39+
import { controls } from '@/shared/routing';
3940

40-
import { controls } from '@/shared/routing'
41-
42-
const routes = [/* ... */]
41+
const routes = [/* ... */];
4342

4443
export const router = createHistoryRouter({
4544
routes,
46-
controls
47-
})
45+
controls,
46+
});
4847
```
4948

5049
Use it anywhere:
5150
```ts
5251
// @/pages/register
53-
import { sample, cancelButtonPressed } from 'effector'
54-
55-
import { controls } from '@/shared/routing'
52+
import { sample } from 'effector';
53+
import { controls } from '@/shared/routing';
5654

57-
const cancelButtonPressed = createEvent<MouseEvent>()
55+
export const cancelButtonPressed = createEvent();
5856

5957
sample({
6058
clock: cancelButtonPressed,
61-
target: controls.back
62-
})
59+
target: controls.back,
60+
});
6361
```

0 commit comments

Comments
 (0)