1
1
import { createEvent , createStore , merge , Scope , scopeBind } from 'effector' ;
2
- import { createBrowserHistory } from 'history' ;
2
+ import { createBrowserHistory , createMemoryHistory } from 'history' ;
3
3
4
4
import { env } from '@box/shared/config' ;
5
5
@@ -10,33 +10,31 @@ export interface HistoryChange {
10
10
action : 'PUSH' | 'POP' | 'REPLACE' ;
11
11
}
12
12
13
- export const history = env . BUILD_ON_CLIENT ? createBrowserHistory ( ) : null ;
13
+ export const history = env . BUILD_ON_CLIENT ? createBrowserHistory ( ) : createMemoryHistory ( ) ;
14
14
15
15
export const $redirectTo = createStore ( '' ) ;
16
16
17
17
// Used in some cases
18
18
export const historyPush = createEvent < string > ( ) ;
19
- export const historyPushParams = createEvent < { search : string } > ( ) ;
20
- export const historyReplace = createEvent < string > ( ) ;
19
+ // export const historyReplace = createEvent<string>();
21
20
22
21
export const historyChanged = createEvent < HistoryChange > ( ) ;
23
22
24
23
export function initializeClientHistory ( scope : Scope ) {
25
24
historyPush . watch ( ( url ) => history ?. push ( url ) ) ;
26
- historyReplace . watch ( ( url ) => history ?. replace ( url ) ) ;
27
- historyPushParams . watch ( ( params ) => history ?. push ( params ) ) ;
28
- const boundHistoryChange = scopeBind ( historyChanged , { scope } ) ;
29
- history ?. listen ( ( { pathname, search, hash } , action ) => {
30
- boundHistoryChange ( { pathname, search, hash, action } ) ;
31
- } ) ;
25
+ // historyReplace.watch((url) => history?.replace(url));
26
+ // const boundHistoryChange = scopeBind(historyChanged, { scope });
27
+ // history?.listen(({ pathname, search, hash }, action) => {
28
+ // boundHistoryChange({ pathname, search, hash, action });
29
+ // });
32
30
}
33
31
34
32
export function initializeServerHistory ( ) {
35
- const historyUpdate = merge ( [ historyPush , historyReplace ] ) ;
36
- $redirectTo . on ( historyUpdate , ( _ , url ) => url ) ;
33
+ // const historyUpdate = merge([historyPush, historyReplace]);
34
+ // $redirectTo.on(historyUpdate, (_, url) => url);
37
35
}
38
36
39
37
export const navigationModel = {
40
38
historyPush,
41
- historyReplace,
39
+ // historyReplace,
42
40
} ;
0 commit comments