extensions/markdown-language-features/server/src/server.ts/update
function registerDynamicClientFeature(
	config: ConfigurationManager,
	isEnabled: (settings: Settings | undefined) => boolean,
	register: () => Promise<Disposable>,
) {
	let registration: Promise<IDisposable> | undefined;
	function update() {
		const settings = config.getSettings();
		if (isEnabled(settings)) {
			if (!registration) {
				registration = register();
			}
		} else {
			registration?.then(x => x.dispose());
			registration = undefined;
		}
	}

	update();
	return config.onDidChangeConfiguration(() => update());
}