@@ -89,27 +89,27 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({
8989 length ( ) : Promise < number >
9090 }
9191
92- const WRITE_DEBOUNCE_MS = 250
92+ const WRITE_DEBOUNCE_MS = 250
9393
94- const storeCache = new Map < string , Promise < StoreLike > > ( )
95- const apiCache = new Map < string , AsyncStorage & { flush : ( ) => Promise < void > } > ( )
96- const memoryCache = new Map < string , StoreLike > ( )
94+ const storeCache = new Map < string , Promise < StoreLike > > ( )
95+ const apiCache = new Map < string , AsyncStorage & { flush : ( ) => Promise < void > } > ( )
96+ const memoryCache = new Map < string , StoreLike > ( )
9797
98- const flushAll = async ( ) => {
99- const apis = Array . from ( apiCache . values ( ) )
100- await Promise . all ( apis . map ( ( api ) => api . flush ( ) . catch ( ( ) => undefined ) ) )
101- }
102-
103- if ( "addEventListener" in globalThis ) {
104- const handleVisibility = ( ) => {
105- if ( document . visibilityState !== "hidden" ) return
106- void flushAll ( )
107- }
98+ const flushAll = async ( ) => {
99+ const apis = Array . from ( apiCache . values ( ) )
100+ await Promise . all ( apis . map ( ( api ) => api . flush ( ) . catch ( ( ) => undefined ) ) )
101+ }
108102
109- window . addEventListener ( "pagehide" , ( ) => void flushAll ( ) )
110- document . addEventListener ( "visibilitychange" , handleVisibility )
103+ if ( "addEventListener" in globalThis ) {
104+ const handleVisibility = ( ) => {
105+ if ( document . visibilityState !== "hidden" ) return
106+ void flushAll ( )
111107 }
112108
109+ window . addEventListener ( "pagehide" , ( ) => void flushAll ( ) )
110+ document . addEventListener ( "visibilitychange" , handleVisibility )
111+ }
112+
113113 const createMemoryStore = ( ) => {
114114 const data = new Map < string , string > ( )
115115 const store : StoreLike = {
0 commit comments