@@ -44,9 +44,6 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
44
44
45
45
let currentRoute = transformLocationToRoute ( reactRouter . state . location , reactRouter . state . matches ) ;
46
46
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- let listeners : ( ( ) => void ) [ ] = [ ] ;
49
-
50
47
reactRouter . getBlocker ( 'beforeGuard' , onBeforeRouteChange ) ;
51
48
52
49
reactRouter . subscribe ( afterRouteChange ) ;
@@ -212,9 +209,13 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
212
209
213
210
async function initReady ( ) : Promise < boolean > {
214
211
return new Promise ( ( resolved , reject ) => {
215
- init ( currentRoute . fullPath , blockerOrJump )
216
- . then ( ( ) => {
217
- reactRouter . initialize ( ) ;
212
+ init ( currentRoute . fullPath )
213
+ . then ( res => {
214
+ if ( ! res ) {
215
+ reactRouter . initialize ( ) ;
216
+ } else {
217
+ reactRouter . initialize ( ) . navigate ( resolve ( res ) . fullPath ) ;
218
+ }
218
219
resolved ( true ) ;
219
220
} )
220
221
. catch ( e => {
@@ -277,23 +278,12 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
277
278
return getRoutes ( ) . find ( route => route . name === key ) ?. meta ;
278
279
}
279
280
280
- function getSnapshot ( ) {
281
- return currentRoute ;
282
- }
283
-
284
281
function resetRoute ( ) {
285
282
// Resets the route matcher so it can begin matching new routes again.
286
283
matcher . resetMatcher ( ) ;
287
284
reactRouter . _internalSetRoutes ( initReactRoutes ) ;
288
285
}
289
286
290
- function subscribe ( listener : ( ) => void ) {
291
- listeners = [ listener ] ;
292
- return ( ) => {
293
- listeners = [ ] ;
294
- } ;
295
- }
296
-
297
287
function removeRoute ( name : string ) {
298
288
const matched = matcher . getRecordMatcher ( name ) ;
299
289
if ( ! matched ) return ;
@@ -320,10 +310,8 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
320
310
removeRoute,
321
311
getRouteMetaByKey,
322
312
forwardRef,
323
- subscribe,
324
313
initReady,
325
314
getRoutes,
326
- getSnapshot,
327
315
resetRoute,
328
316
addReactRoutes,
329
317
push,
0 commit comments