@@ -17,7 +17,7 @@ const snapshotLocation = './test/playground/snapshot/';
1717 */
1818async function setupSwitcher ( local ) {
1919 Client . buildContext ( { url, apiKey, domain, component, environment } , { local, logger : true } ) ;
20- await Client . loadSnapshot ( false , local )
20+ await Client . loadSnapshot ( { watchSnapshot : false , fetchRemote : local } )
2121 . then ( version => console . log ( 'Snapshot loaded - version:' , version ) )
2222 . catch ( ( ) => console . log ( 'Failed to load Snapshot' ) ) ;
2323}
@@ -131,28 +131,30 @@ const _testBypasser = async () => {
131131// Requires remote API
132132const _testWatchSnapshot = async ( ) => {
133133 Client . buildContext ( { url, apiKey, domain, component, environment } , { snapshotLocation, local : true , logger : true } ) ;
134- await Client . loadSnapshot ( false , true )
134+ await Client . loadSnapshot ( { watchSnapshot : false , fetchRemote : true } )
135135 . then ( ( ) => console . log ( 'Snapshot loaded' ) )
136136 . catch ( ( ) => console . log ( 'Failed to load Snapshot' ) ) ;
137137
138138 const switcher = Client . getSwitcher ( ) ;
139-
140- Client . watchSnapshot (
141- async ( ) => console . log ( 'In-memory snapshot updated' , await switcher . isItOn ( SWITCHER_KEY ) ) ,
142- ( err ) => console . log ( err ) ) ;
139+
140+ Client . watchSnapshot ( {
141+ success : async ( ) => console . log ( 'In-memory snapshot updated' , await switcher . isItOn ( SWITCHER_KEY ) ) ,
142+ reject : ( err ) => console . log ( err )
143+ } ) ;
143144} ;
144145
145146// Requires remote API
146147const _testSnapshotAutoUpdate = async ( ) => {
147148 Client . buildContext ( { url, apiKey, domain, component, environment } ,
148149 { local : true , logger : true } ) ;
149150
150- await Client . loadSnapshot ( false , true ) ;
151+ await Client . loadSnapshot ( { watchSnapshot : false , fetchRemote : true } ) ;
151152 const switcher = Client . getSwitcher ( ) ;
152153
153- Client . scheduleSnapshotAutoUpdate ( 3 ,
154- ( updated ) => console . log ( 'In-memory snapshot updated' , updated ) ,
155- ( err ) => console . log ( err ) ) ;
154+ Client . scheduleSnapshotAutoUpdate ( 1 , {
155+ success : ( updated ) => console . log ( 'In-memory snapshot updated' , updated ) ,
156+ reject : ( err ) => console . log ( err )
157+ } ) ;
156158
157159 setInterval ( async ( ) => {
158160 const time = Date . now ( ) ;
0 commit comments