-
Notifications
You must be signed in to change notification settings - Fork 106
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
async validate #94
base: main
Are you sure you want to change the base?
async validate #94
Conversation
🦋 Changeset detectedLatest commit: 19a1903 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@natemoo-re thoughts? |
This looks good! I pushed a change to set a Also adds a |
Feel free to merge if you feel comfortable with this! |
Nice solution! I'll make sure to try it out and merge if appeased 😉 |
The password prompt seems to be broken now (compared to the main branch — even after handling the |
d3616a1
to
68abb81
Compare
It seems like |
@@ -172,7 +177,17 @@ export default class Prompt { | |||
|
|||
if (key?.name === 'return') { | |||
if (this.opts.validate) { | |||
const problem = this.opts.validate(this.value); | |||
this.state = 'validate'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the race
/timeout
is sorted, shouldn't this move closer to the render
? No need to set it if never rendered?
Would have to use something like: https://stackoverflow.com/a/39852372 |
Gah, for unknown reason, the password prompt doesn't like Simply add an Not sure if readline doesn't like async or something. |
Pushed fix for the timeout issue, but have yet to resolve the password prompt not working. I can't understand why it works for text but not password... |
@natemoo-re @ulken @cpreston321 I looked at this, and seems the password prompt was losing the prompt context during async validation, I fixed it on this commit d258379, please check it out! |
How is the progress on this? |
Took a stab at supporting async validation.
Currently, the UX is suffering, though. The program seemingly hangs, without any feedback to the user. We should probably kick off a spinner or similar.
Potentially by emitting a
validate
event from core to allow styled prompts to take appropriate action? Or introducing a new state and doing an intermediate render?Related to #92