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:
parent
78f6f8ef54
commit
770c6b80f1
9
src/common/utils/debouncePromise.ts
Executable file
9
src/common/utils/debouncePromise.ts
Executable 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);
|
||||
});
|
||||
}
|
||||
@ -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 "./camelCase"
|
||||
export * from "./splitArray"
|
||||
export * from "./getRandId"
|
||||
export * from "./cloneJson"
|
||||
export * from "./debouncePromise"
|
||||
export * from "./defineGlobal"
|
||||
export * from "./getRandId"
|
||||
export * from "./splitArray"
|
||||
export * from "./saveToAppFiles"
|
||||
export * from "./singleton"
|
||||
export * from "./cloneJson"
|
||||
|
||||
@ -3,7 +3,7 @@ import type { KubeObjectDetailsProps, KubeObjectListLayoutProps, KubeObjectMenuP
|
||||
import type React from "react";
|
||||
|
||||
import { observable } from "mobx";
|
||||
import { autobind } from "../utils/autobind";
|
||||
import { autobind } from "../utils";
|
||||
import { KubeApi } from "./kube-api";
|
||||
|
||||
export interface ApiComponents {
|
||||
|
||||
@ -5,7 +5,7 @@ import { FitAddon } from "xterm-addon-fit";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
import { TerminalApi } from "../../api/terminal-api";
|
||||
import { themeStore } from "../../theme.store";
|
||||
import { autobind } from "../../utils/autobind";
|
||||
import { autobind } from "../../utils";
|
||||
|
||||
export class Terminal {
|
||||
static spawningPool: HTMLElement;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { computed, observable, reaction } from "mobx";
|
||||
import { autobind } from "./utils/autobind";
|
||||
import { autobind } from "./utils";
|
||||
import { userStore } from "../common/user-store";
|
||||
import logger from "../main/logger";
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
};
|
||||
@ -3,21 +3,18 @@
|
||||
export const noop: any = Function();
|
||||
export const isElectron = !!navigator.userAgent.match(/Electron/);
|
||||
|
||||
export * from '../../common/utils/camelCase'
|
||||
export * from '../../common/utils/base64'
|
||||
export * from "../../common/utils"
|
||||
|
||||
export * from './autobind'
|
||||
export * from './cssVar'
|
||||
export * from './cssNames'
|
||||
export * from './eventEmitter'
|
||||
export * from './downloadFile'
|
||||
export * from './prevDefault'
|
||||
export * from './createStorage'
|
||||
export * from './interval'
|
||||
export * from './debouncePromise'
|
||||
export * from './copyToClipboard'
|
||||
export * from './formatDuration'
|
||||
export * from './isReactNode'
|
||||
export * from './convertMemory'
|
||||
export * from './convertCpu'
|
||||
export * from './metricUnitsToNumber'
|
||||
export * from "./cssVar"
|
||||
export * from "./cssNames"
|
||||
export * from "./eventEmitter"
|
||||
export * from "./downloadFile"
|
||||
export * from "./prevDefault"
|
||||
export * from "./createStorage"
|
||||
export * from "./interval"
|
||||
export * from "./copyToClipboard"
|
||||
export * from "./formatDuration"
|
||||
export * from "./isReactNode"
|
||||
export * from "./convertMemory"
|
||||
export * from "./convertCpu"
|
||||
export * from "./metricUnitsToNumber"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user