feat: add WaitForMsg function#377
Open
Broderick-Westrope wants to merge 3 commits intocharmbracelet:mainfrom
Open
feat: add WaitForMsg function#377Broderick-Westrope wants to merge 3 commits intocharmbracelet:mainfrom
Broderick-Westrope wants to merge 3 commits intocharmbracelet:mainfrom
Conversation
Author
Author
|
Hi @caarlos0, just bumping this one :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #310. Please see the linked issue for more context on the goals of (and motivations for) this PR.
Duplicate of #311; I had some issues with GitHub account that deleted the forked repo :(
Changes:
WaitForfunction toWaitForOutputto avoid confusion with the new, similarly named method.msgbuffertype. This is a simple mutex-protected slice oftea.Msg.msgCaptureModeltype. Implementstea.Model. Contains a childtea.Modeland amsgBuffer. Everytea.Msgis stored in the buffer before being sent to the child model.NewTestModelso that the provided model is now wrapped in amsgCaptureModel.TestOption.TestModelWaitForMsgwhich takes a condition function and returns atea.Msg. Much of the code for this was copied from theWaitForfunction (now calledWaitForOutput). At a set interval it will check the messages stored within the buffer and if any matches the provided condition function it will be returned.Please note this is not a complete solution. Instead, this is intended to spark a discussion. I am happy to put in the required work to polish this off, but I want to make sure it is something that the Charm team wants in their repo before spending more time on it :)