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

Enhance Event Emitter to ignore events generated by same process ID #2279

Closed
t1m0thyj opened this issue Sep 27, 2024 · 1 comment · Fixed by #2323 or #2313
Closed

Enhance Event Emitter to ignore events generated by same process ID #2279

t1m0thyj opened this issue Sep 27, 2024 · 1 comment · Fixed by #2323 or #2313
Labels
enhancement New feature or request priority-medium Not functioning - next quarter if capacity permits

Comments

@t1m0thyj
Copy link
Member

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

As a developer of a Zowe app like Zowe Explorer that uses the Imperative event emitter, I register the ON_VAULT_CHANGED event because I want to know when an external app has updated credentials. The event also fires when my own app has updated credentials, which is not ideal as it may result in a duplicate refresh operation (e.g. the "Update Credentials" dialog shows twice).

Describe your enhancement idea

Add an ignoreSameProcess option when registering to watch for an event, which checks the PID (process ID) of the event and prevents events from being emitted to the same app that triggered them.

Describe alternatives you've considered

An alternative workaround is for apps like ZE to modify the EventProcessor prototype to skip duplicate events, but this is kind of hacky:

const oldEmitZoweEvent = (imperative.EventProcessor.prototype as any).emitZoweEvent;
(imperative.EventProcessor.prototype as any).emitZoweEvent = function (eventName: string): void {
    if (eventName === imperative.ZoweUserEvents.ON_VAULT_CHANGED) {
        Constants.IGNORE_VAULT_CHANGE = true;
    }
    oldEmitZoweEvent.call(this, eventName);
};
imperative.EventOperator.getWatcher().subscribeUser(imperative.ZoweUserEvents.ON_VAULT_CHANGED, async () => {
    if (Constants.IGNORE_VAULT_CHANGE) {
        Constants.IGNORE_VAULT_CHANGE = false;
        return;
    }
    // Handle event here
});

Provide any additional context

Related to this Zowe Explorer PR: zowe/zowe-explorer-vscode#3157

@t1m0thyj t1m0thyj added enhancement New feature or request new The issue wasn't triaged yet labels Sep 27, 2024
@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Sep 27, 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-medium Not functioning - next quarter if capacity permits and removed new The issue wasn't triaged yet labels Sep 30, 2024
@zowe-robot zowe-robot moved this from New Issues to Medium Priority in Zowe CLI Squad Sep 30, 2024
@t1m0thyj t1m0thyj linked a pull request Oct 28, 2024 that will close this issue
4 tasks
@t1m0thyj t1m0thyj linked a pull request Nov 11, 2024 that will close this issue
4 tasks
@github-project-automation github-project-automation bot moved this from Medium Priority to Closed in Zowe CLI Squad Nov 11, 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-medium Not functioning - next quarter if capacity permits
Projects
Status: Closed
2 participants