Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debounce utility method to Core SDK #2364

Open
t1m0thyj opened this issue Nov 15, 2024 · 1 comment
Open

Add debounce utility method to Core SDK #2364

t1m0thyj opened this issue Nov 15, 2024 · 1 comment
Labels
enhancement New feature or request priority-low Legit issue but cosmetic or nice-to-have

Comments

@t1m0thyj
Copy link
Member

Is your feature or enhancement request related to a problem or limitation? Please describe

I wish the Core SDK provided a method that could be used to debounce Node.js fs.watch events.

Describe your enhancement idea

Add a debounce utility method - this could be implemented as a decorator like the following:

function Debounce(delay: number) {
    return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
        let timeoutId: ReturnType<typeof setTimeout>;
        const originalMethod = descriptor.value;

        descriptor.value = function (...args: any[]) {
            if (timeoutId) {
                clearTimeout(timeoutId);
            }
            timeoutId = setTimeout(() => originalMethod.apply(this, args), delay);
        };

        return descriptor;
    };
}

Describe alternatives you've considered

Currently the Imperative Event Emitter and Zowe Explorer have each implemented a solution for debouncing events, but it would be nice if they could share a common one.

Provide any additional context

Example of how to use the decorator above:

class MyClass {
    @Debounce(100)
    public static myMethod() {
        console.log("Method 1 called");
    }

    @Debounce(100)
    public static myOtherMethod() {
        console.log("Method 2 called");
    }
}

MyClass.myMethod();
MyClass.myOtherMethod();
MyClass.myMethod();
@t1m0thyj t1m0thyj added enhancement New feature or request new The issue wasn't triaged yet labels Nov 15, 2024
@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Nov 15, 2024
Copy link

Thank you for raising this enhancement request.
The community has 90 days to vote on it.
If the enhancement receives at least 5 upvotes, it is added to our development backlog.
If it receives fewer votes, the issue is closed.

@JTonda JTonda added priority-low Legit issue but cosmetic or nice-to-have and removed new The issue wasn't triaged yet labels Nov 18, 2024
@zowe-robot zowe-robot moved this from New Issues to Low Priority in Zowe CLI Squad Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-low Legit issue but cosmetic or nice-to-have
Projects
Status: Low Priority
Development

No branches or pull requests

2 participants