Add LensRendererExtension.isEnabledForCluster (#1502)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2020-11-24 16:15:14 +02:00
1 parent cb14d77a56
commit 1be86b34f4
3 files changed
+30 -13

No files matched your search

+4 -3
View File
@@ -67,15 +67,16 @@ export class LensExtension {
}
}
async whenEnabled(handlers: () => Function[]) {
async whenEnabled(handlers: () => Promise<Function[]>) {
const disposers: Function[] = [];
const unregisterHandlers = () => {
disposers.forEach(unregister => unregister());
disposers.length = 0;
};
const cancelReaction = reaction(() => this.isEnabled, isEnabled => {
const cancelReaction = reaction(() => this.isEnabled, async (isEnabled) => {
if (isEnabled) {
disposers.push(...handlers());
const handlerDisposers = await handlers();
disposers.push(...handlerDisposers);
} else {
unregisterHandlers();
}