1
1
import { defaultConfigOptions } from './web-preset'
2
2
import { IS_SERVER } from './env'
3
- import { UNDEFINED , mergeObjects } from './helper'
3
+ import { UNDEFINED , mergeObjects , noop } from './helper'
4
4
import { internalMutate } from './mutate'
5
5
import { SWRGlobalState } from './global-state'
6
6
import * as revalidateEvents from '../constants/revalidate-events'
@@ -41,6 +41,7 @@ export const initCache = <Data = any>(
41
41
const mutate = internalMutate . bind ( UNDEFINED , provider ) as ScopedMutator <
42
42
Data
43
43
>
44
+ let unsubscribe = noop
44
45
45
46
// Update the state if it's new, or the provider has been extended.
46
47
SWRGlobalState . set ( provider , [
@@ -55,7 +56,6 @@ export const initCache = <Data = any>(
55
56
56
57
// This is a new provider, we need to initialize it and setup DOM events
57
58
// listeners for `focus` and `reconnect` actions.
58
- let unscubscibe = ( ) => { }
59
59
if ( ! IS_SERVER ) {
60
60
const releaseFocus = opts . initFocus (
61
61
revalidateAllKeys . bind (
@@ -71,7 +71,7 @@ export const initCache = <Data = any>(
71
71
revalidateEvents . RECONNECT_EVENT
72
72
)
73
73
)
74
- unscubscibe = ( ) => {
74
+ unsubscribe = ( ) => {
75
75
releaseFocus && releaseFocus ( )
76
76
releaseReconnect && releaseReconnect ( )
77
77
}
@@ -80,6 +80,6 @@ export const initCache = <Data = any>(
80
80
// We might want to inject an extra layer on top of `provider` in the future,
81
81
// such as key serialization, auto GC, etc.
82
82
// For now, it's just a `Map` interface without any modifications.
83
- return [ provider , mutate , unscubscibe ]
83
+ return [ provider , mutate , unsubscribe ]
84
84
}
85
85
}
0 commit comments