Skip to content

Commit 0fb81da

Browse files
Merge branch 'zhiyuanliang/register-all-refresh' of https://github.com/Azure/AppConfiguration-JavaScriptProvider into zhiyuanliang/enforce-api-version-for-cdn
2 parents eec7114 + 01a7034 commit 0fb81da

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,26 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
290290
}
291291
}
292292

293+
/**
294+
* Registers a callback function to be called when the configuration is refreshed.
295+
*/
296+
onRefresh(listener: () => any, thisArg?: any): Disposable {
297+
if (!this.#refreshEnabled && !this.#featureFlagRefreshEnabled) {
298+
throw new Error("Refresh is not enabled for key-values or feature flags.");
299+
}
300+
301+
const boundedListener = listener.bind(thisArg);
302+
this.#onRefreshListeners.push(boundedListener);
303+
304+
const remove = () => {
305+
const index = this.#onRefreshListeners.indexOf(boundedListener);
306+
if (index >= 0) {
307+
this.#onRefreshListeners.splice(index, 1);
308+
}
309+
};
310+
return new Disposable(remove);
311+
}
312+
293313
async #refreshTasks(): Promise<void> {
294314
const refreshTasks: Promise<boolean>[] = [];
295315
if (this.#refreshEnabled) {
@@ -319,26 +339,6 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
319339
}
320340
}
321341

322-
/**
323-
* Registers a callback function to be called when the configuration is refreshed.
324-
*/
325-
onRefresh(listener: () => any, thisArg?: any): Disposable {
326-
if (!this.#refreshEnabled && !this.#featureFlagRefreshEnabled) {
327-
throw new Error("Refresh is not enabled for key-values or feature flags.");
328-
}
329-
330-
const boundedListener = listener.bind(thisArg);
331-
this.#onRefreshListeners.push(boundedListener);
332-
333-
const remove = () => {
334-
const index = this.#onRefreshListeners.indexOf(boundedListener);
335-
if (index >= 0) {
336-
this.#onRefreshListeners.splice(index, 1);
337-
}
338-
};
339-
return new Disposable(remove);
340-
}
341-
342342
/**
343343
* Loads configuration settings from App Configuration, either key-value settings or feature flag settings.
344344
* Additionally, updates the `pageEtags` property of the corresponding @see PagedSettingSelector after loading.

0 commit comments

Comments
 (0)