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

Feature request: Support for "done" callback for all prompt types #1211

Closed
remisture opened this issue Apr 14, 2023 · 4 comments
Closed

Feature request: Support for "done" callback for all prompt types #1211

remisture opened this issue Apr 14, 2023 · 4 comments

Comments

@remisture
Copy link

Could you please add support for some sort of callback for when the prompt is finished (and valid)?

const STORAGE_NAME = 'name';

await inquirer.prompt({
	type: 'input',
	name: 'name',
	message: 'What is your name?',
	default: localStorage.getItem(STORAGE_NAME),
	done: (answer) => localStorage.setItem(STORAGE_NAME, answer),
});
@SBoudrias
Copy link
Owner

Hi @remisture, how is this different from waiting for the promise to resolve?

@remisture
Copy link
Author

You're right, that's what I do now. I guess the example is bad :) It's useful when you have an array of prompts, and quit halfway through for some reason :)

await inquirer.prompt([
   { type: 'input', name: 'input1', message: 'Message 1' },
   { type: 'input', name: 'input2', message: 'Message 2' },
   { type: 'input', name: 'input3', message: 'Message 3' }
]);

@SBoudrias
Copy link
Owner

Hi, with the release of the new API, I'm not really open to adding more control flow. The reasons are somewhat covered in the release announcement #1214 - and with the new API, you'd own control of the flow completely; this mean you'll get the answer after each prompt.

Thanks for reaching out, and I hope that alternative will work for you.

@remisture
Copy link
Author

No worries :)

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