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

Is there an exit event / listener? #38

Open
adam-lynch opened this issue Aug 28, 2020 · 2 comments
Open

Is there an exit event / listener? #38

adam-lynch opened this issue Aug 28, 2020 · 2 comments

Comments

@adam-lynch
Copy link

adam-lynch commented Aug 28, 2020

I ran into an issue where when using useInput or ink-select-input; pressing ctrl+c exits the app but not the process.

This is probably because our app has live connections. Is there a way I can subscribe to when the React app exits? I know there's waitUntilExit but I don't think that's accessible via Pastel (correct me if I'm wrong).

If exitOnCtrlC was set to false, I could check for key.ctrl && input === "c" in the useInput callback, and then call process.exit(0). I've confirmed this by editing the hook in node_modules. But:

  1. I want it to disable exitOnCtrlC at all.
  2. I don't think it can be disabled via Pastel (Unable to pass options to Ink render() command #35).
  3. I shouldn't have to manually handle ctrl+c anyway so this isn't a real solution 🤷‍♂️.

The workaround I'm using right now is to manually listen to stdin via useStdin. When ctrl+c is pressed (I've copied the logic from useInput), I call process.exit(0).

The awkward thing is that if any third-party component uses useInput, a workaround like this has to be used.

I think this is related to #8

@JakeAdler
Copy link

JakeAdler commented Sep 11, 2020

@adam-lynch You can simply import and edit the useInput method (these lines), and handle ctrl-c yourself (call exit() and process.exit(0))

@adam-lynch
Copy link
Author

where are you suggesting I do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants