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

Add return tea.cmd from event handlers #28

Merged
merged 1 commit into from
Nov 15, 2023
Merged

Add return tea.cmd from event handlers #28

merged 1 commit into from
Nov 15, 2023

Conversation

wagoodman
Copy link
Contributor

This makes a breaking change to the EventHandler such that it can also return a tea.Cmd. Today the models that are returned from the handlers are meant to act like factories, returning only newly created models, which processing downstream will call Init() on the models to get any tea.Cmds. However, if you are looking to respond to an event on the bus that will not create a new model to be managed by downstream processing but instead a new model that will be subsumed into an existing model, there isn't a way to communicate the subsumed model's Init() commands.

This PR changes this behavior by allowing for event handlers to optionally also return a tea.Cmd for new models that are not returned by the handler to.

@wagoodman wagoodman requested a review from a team November 14, 2023 21:46
@wagoodman wagoodman marked this pull request as ready for review November 14, 2023 21:47
@wagoodman wagoodman merged commit 8f2267d into main Nov 15, 2023
3 checks passed
@wagoodman wagoodman deleted the return-cmd branch November 15, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants