Extract Looping Mechanisms #154
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've successfully implemented an asynchronous, non-blocking prompt, which can simply extend our existing abstract prompt, leaving backwards compatibility unaffected. By using a
reactphpevent loop, I'm able to trigger renders and do other operations at any time since reading terminal input is no longer a blocking operation. This can almost certainly remove our reliance onforkingusing theProcess Controlextension in theSpinnerclass,and there's a slight chance that it could solve our Windows story (I still have to verify this, so don't quote me). It also happens to enable me to do some really cool stuff involving websockets that I'll have ready soon.However, none of that is in this PR.
This PR is exclusively to make my new feature compatible with Laravel Prompts irrespective of its ultimate home (I'm totally fine with it living in my
community promptspackage if that's what has to happen).selftostaticwhen setting or getting theConsoleOutputobject so that the$outputstatic property is set on the child.promptmethod which can now also be overridden in an extending class.Nothingsupport class.Since the
whileloop is now a function, if we were to rely on returningnullto continue looping, we could no longer returnnullfrom any prompt. Sincenullis a valid return value, I needed a way to, in effect, check for avoidreturn.edit: I checked, and non-blocking i/o still wont work on Windows.