Inquirer.js: FR: Show progress indicator on async validate

Created on 9 Jan 2018  路  9Comments  路  Source: SBoudrias/Inquirer.js

I have an async validation that takes a while. When the user presses enter, nothing seems to happen, until the validation completes. Is it possible to add some visual indication (for example, changing the question mark into a progress spinner), while the validation is running. The UI feels unresponsive now.

Unfortunately, I can't console.log something like that myself, because if the validation fails, any logging will cause the question to repeat, which is not what I want.

enhancement feature

Most helpful comment

@SBoudrias Please see my PR for implementation details.

All 9 comments

This would be a great improvement I believe.

Anyone wants to work on a PR?

With some guidance, I might. It seems that functionality would wrap this call: https://github.com/SBoudrias/Inquirer.js/blob/master/lib/prompts/base.js#L87 with something like startSpinner -> call validate -> resetSpinner. Would that be the right place to put this?

This is the implementation I have now. I added another option validatingText to a question for it too.
spinner

This can also be extended to filtering, which is also async:
spinnerfiltervalidate
In the filtering case, I also added updating the display with the filtered answer after filtering is complete.

@SBoudrias Please see my PR for implementation details.

any update on this @kbrandwijk @SBoudrias ? I would love to have this!

The PR apparently needs something (test case?) but I don't have any time to do it...

bummer :(

@benmonro Feel free to contribute if you'd like to 'have this'...

Check out the ora module by Sindre Sorhus.

https://www.npmjs.com/package/ora

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronshaf picture aaronshaf  路  7Comments

aguerrieri picture aguerrieri  路  6Comments

adalinesimonian picture adalinesimonian  路  6Comments

christav picture christav  路  5Comments

bugzpodder picture bugzpodder  路  4Comments