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

fix: process nested sequence messages in order #843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions tea.go
Expand Up @@ -384,6 +384,14 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
continue
}

// process nested sequence messages in order
if sequenceMsg, ok := msg.(sequenceMsg); ok {
for _, cmd := range sequenceMsg {
p.Send(cmd())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we have deeply nested sequences (3+)? Imagine we have a cmd like:

sequenceMsg: [
    sequenceMsg: [
        sequenceMsg: [customMsg11, customMsg12],
        sequenceMsg: [customMsg21, customMsg22]
    ]
]

where each Msg represents a cmd and what will be returned after running it.

Doesn't this solution only work for the first two sequences? The outermost sequence is handled by line 363, and then the second sequence is handled here, but the third and fourth sequences (with the customMsg*s) will be done concurrently -- customMsg11 will happen before customMsg12, but customMsg21 could occur before customMsg11, after customMsg11, or after customMsg12. Am I missing something?

}
continue
}

p.Send(msg)
}
}()
Expand Down