@@ -15,17 +15,17 @@ import { querySync } from 'atomic-router';
15
15
### Basic example
16
16
17
17
``` ts
18
- import { createStore } from ' effector'
19
- import { createRoute , querySync } from ' atomic-router'
18
+ import { createStore } from ' effector' ;
19
+ import { querySync } from ' atomic-router' ;
20
20
21
- import { controls } from ' @/shared/routing'
21
+ import { controls } from ' @/shared/routing' ;
22
22
23
- const $utmSource = createStore (" " )
23
+ const $utmSource = createStore (" " );
24
24
25
25
querySync ({
26
26
source: { utm_source: $utmSource },
27
- controls
28
- })
27
+ controls ,
28
+ });
29
29
```
30
30
31
31
This will
@@ -37,20 +37,20 @@ This will
37
37
You can pass ` route ` param if you want this sync to work only for a specific route:
38
38
39
39
``` ts
40
- import { createStore } from ' effector'
41
- import { createRoute , querySync } from ' atomic-router'
40
+ import { createStore } from ' effector' ;
41
+ import { createRoute , querySync } from ' atomic-router' ;
42
42
43
- import { controls } from ' @/shared/routing'
43
+ import { controls } from ' @/shared/routing' ;
44
44
45
- const searchRoute = createRoute ()
45
+ const searchRoute = createRoute ();
46
46
47
- const $q = createStore (" " )
47
+ const $q = createStore (" " );
48
48
49
49
querySync ({
50
50
source: { q: $q },
51
- route: searchRoute ,
52
- controls
53
- })
51
+ route: searchRoute ,
52
+ controls ,
53
+ });
54
54
```
55
55
56
56
### With a ` clock `
@@ -59,29 +59,29 @@ If we don't want to spam route updates, there's a `clock` parameter.
59
59
If it's passed, ` querySync ` will update route only when ` clock ` it's triggered:
60
60
61
61
``` ts
62
- import { createRoute , querySync } from ' atomic-router'
63
- import { createStore , createEvent } from ' effector'
62
+ import { createRoute , querySync } from ' atomic-router' ;
63
+ import { createStore , createEvent } from ' effector' ;
64
64
65
- import { controls } from ' @/shared/routing'
65
+ import { controls } from ' @/shared/routing' ;
66
66
67
- const canvasEditorRoute = createRoute ()
67
+ const canvasEditorRoute = createRoute ();
68
68
69
- const canvasDragged = createEvent ()
70
- const canvasDragEnded = createEvent ()
69
+ const canvasDragged = createEvent ();
70
+ const canvasDragEnded = createEvent ();
71
71
72
- const $x = createStore (' 0' )
73
- const $y = createStore (' 0' )
72
+ const $x = createStore (' 0' );
73
+ const $y = createStore (' 0' );
74
74
75
- $x .on (canvasDragged , (_ , { x }) => x )
75
+ $x .on (canvasDragged , (_ , { x }) => x );
76
76
77
- $y .on (canvasDragged , (_ , { y }) => y )
77
+ $y .on (canvasDragged , (_ , { y }) => y );
78
78
79
79
querySync ({
80
80
source: { x: $x , y: $y },
81
81
route: canvasEditorRoute ,
82
82
clock: canvasDragEnded ,
83
- controls
84
- })
83
+ controls ,
84
+ });
85
85
```
86
86
87
87
## ` cleanup ` parameter
@@ -97,10 +97,10 @@ querySync({
97
97
// Strip empty params ('', 0, false, null)
98
98
empty: true ,
99
99
// Preserves params that should've been removed by irerelevant/empty params
100
- preserve: [' utm_source' ]
100
+ preserve: [' utm_source' ],
101
101
},
102
- controls
103
- })
102
+ controls ,
103
+ });
104
104
```
105
105
106
106
- ` cleanup ` is optional. Default strategy is ` { irrelevant: true, empty: false, preserve: [] } `
0 commit comments