@@ -211,7 +211,7 @@ const settings = await load(endpoint, credential, {
211
211
212
212
Setting up ` refreshOptions ` alone won ' t automatically refresh the configuration. You need to call the `refresh` method on `AzureAppConfiguration` instance returned by the `load` method to trigger a refresh.
213
213
214
- ` ` ` typescript
214
+ ` ` ` typescript
215
215
// this call is not blocking, the configuration will be updated asynchronously
216
216
settings.refresh();
217
217
` ` `
@@ -229,6 +229,42 @@ server.use((req, res, next) => {
229
229
230
230
Even if the refresh call fails for any reason , your application will continue to use the cached configuration . Another attempt will be made when the configured refresh interval has passed and the refresh call is triggered by your application activity . Calling ` refresh ` is a no - op before the configured refresh interval elapses , so its performance impact is minimal even if it ' s called frequently.
231
231
232
+ ### Custom refresh callback
233
+
234
+ The ` onRefresh ` method lets you custom callback functions that will be invoked each time the local configuration is successfully updated with changes from the Azure App Configuration store . It returns a Disposable object , which you can use to remove the registered callback
235
+
236
+ ` ` ` typescript
237
+ const settings = await load(endpoint, credential, {
238
+ refreshOptions: {
239
+ enabled: true
240
+ }
241
+ });
242
+ const disposer = settings.onRefresh(() => {
243
+ console.log("Config refreshed.");
244
+ });
245
+
246
+ settings.refresh();
247
+ // Once the refresh is successful, the callback function you registered will be executed.
248
+ // In this example, the message "Config refreshed" will be printed.
249
+
250
+ disposer.dispose();
251
+ ` ` `
252
+
253
+ ### Refresh on sentinel key (Legacy )
254
+
255
+ A sentinel key is a key that you update after you complete the change of all other keys . The configuration provider will monitor the sentinel key instead of all selected key - values . When a change is detected , your app refreshes all configuration values .
256
+
257
+ ` ` ` typescript
258
+ const settings = await load(endpoint, credential, {
259
+ refreshOptions: {
260
+ enabled: true,
261
+ watchedSettings: [
262
+ { key: "sentinel" }
263
+ ]
264
+ }
265
+ });
266
+ ` ` `
267
+
232
268
For more information about refresh configuration , go to [Use dynamic configuration in JavaScript ](./ enable - dynamic - configuration - javascript .md ).
233
269
234
270
## Feature flag
@@ -241,7 +277,7 @@ const settings = await load(endpoint, credential, {
241
277
enabled: true,
242
278
selectors: [ { keyFilter: "*", labelFilter: "Prod" } ],
243
279
refresh: {
244
- enabled: true,
280
+ enabled: true, // the refresh for feature flags need to be enbaled in addition to key-values
245
281
refreshIntervalInMs: 10_000
246
282
}
247
283
}
0 commit comments