1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

move autobind and debouncePromise to common/utils (#1081)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-10-14 07:36:19 -04:00 committed by GitHub
parent 78f6f8ef54
commit 770c6b80f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 32 deletions

View File

@ -0,0 +1,9 @@
// Debouncing promise evaluation
export function debouncePromise<T, F extends any[]>(func: (...args: F) => T | Promise<T>, timeout = 0): (...args: F) => Promise<T> {
let timer: NodeJS.Timeout;
return (...params: any[]) => new Promise((resolve, reject) => {
clearTimeout(timer);
timer = setTimeout(() => resolve(func.apply(this, params)), timeout);
});
}

View File

@ -1,7 +1,14 @@
// Common utils (main/renderer) // Common utils (main OR renderer)
export * from "./app-version"
export * from "./autobind"
export * from "./base64" export * from "./base64"
export * from "./camelCase" export * from "./camelCase"
export * from "./splitArray" export * from "./cloneJson"
export * from "./getRandId" export * from "./debouncePromise"
export * from "./defineGlobal"
export * from "./getRandId"
export * from "./splitArray"
export * from "./saveToAppFiles"
export * from "./singleton"
export * from "./cloneJson" export * from "./cloneJson"

View File

@ -3,7 +3,7 @@ import type { KubeObjectDetailsProps, KubeObjectListLayoutProps, KubeObjectMenuP
import type React from "react"; import type React from "react";
import { observable } from "mobx"; import { observable } from "mobx";
import { autobind } from "../utils/autobind"; import { autobind } from "../utils";
import { KubeApi } from "./kube-api"; import { KubeApi } from "./kube-api";
export interface ApiComponents { export interface ApiComponents {

View File

@ -5,7 +5,7 @@ import { FitAddon } from "xterm-addon-fit";
import { dockStore, TabId } from "./dock.store"; import { dockStore, TabId } from "./dock.store";
import { TerminalApi } from "../../api/terminal-api"; import { TerminalApi } from "../../api/terminal-api";
import { themeStore } from "../../theme.store"; import { themeStore } from "../../theme.store";
import { autobind } from "../../utils/autobind"; import { autobind } from "../../utils";
export class Terminal { export class Terminal {
static spawningPool: HTMLElement; static spawningPool: HTMLElement;

View File

@ -1,5 +1,5 @@
import { computed, observable, reaction } from "mobx"; import { computed, observable, reaction } from "mobx";
import { autobind } from "./utils/autobind"; import { autobind } from "./utils";
import { userStore } from "../common/user-store"; import { userStore } from "../common/user-store";
import logger from "../main/logger"; import logger from "../main/logger";

View File

@ -1,9 +0,0 @@
// Debouncing promise evaluation
export const debouncePromise = function (promisedFunc: Function, timeout = 0) {
let timer: number;
return (...params: any[]) => new Promise((resolve, reject) => {
clearTimeout(timer);
timer = window.setTimeout(() => resolve(promisedFunc.apply(this, params)), timeout);
});
};

View File

@ -3,21 +3,18 @@
export const noop: any = Function(); export const noop: any = Function();
export const isElectron = !!navigator.userAgent.match(/Electron/); export const isElectron = !!navigator.userAgent.match(/Electron/);
export * from '../../common/utils/camelCase' export * from "../../common/utils"
export * from '../../common/utils/base64'
export * from './autobind' export * from "./cssVar"
export * from './cssVar' export * from "./cssNames"
export * from './cssNames' export * from "./eventEmitter"
export * from './eventEmitter' export * from "./downloadFile"
export * from './downloadFile' export * from "./prevDefault"
export * from './prevDefault' export * from "./createStorage"
export * from './createStorage' export * from "./interval"
export * from './interval' export * from "./copyToClipboard"
export * from './debouncePromise' export * from "./formatDuration"
export * from './copyToClipboard' export * from "./isReactNode"
export * from './formatDuration' export * from "./convertMemory"
export * from './isReactNode' export * from "./convertCpu"
export * from './convertMemory' export * from "./metricUnitsToNumber"
export * from './convertCpu'
export * from './metricUnitsToNumber'