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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose list.FilterMachesMsg #77

Merged
merged 2 commits into from Jan 11, 2022
Merged

expose list.FilterMachesMsg #77

merged 2 commits into from Jan 11, 2022

Conversation

jon4hz
Copy link
Contributor

@jon4hz jon4hz commented Nov 9, 2021

No description provided.

@meowgorithm meowgorithm merged commit 7a728ea into charmbracelet:master Jan 11, 2022
@meowgorithm
Copy link
Member

meowgorithm commented Jan 11, 2022

Thanks for this @jon4hz!

For those tuned in, some background here: we're generally erring on exposing internal messages now to make it easier to avoid routing all messages through various Bubbles if need be. In other words, catch-all updates like this:

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    // Pass every single message through the list's update function
    var cmd tea.Cmd
    m.list = m.list.Update(msg)
}

Can now also be avoided if desired:

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg.(type) {
        case list.FilterMsg:
            var cmd tea.Cmd
            m.list = m.list.Update(msg)
            return m, cmd
    }
}

The former example is still totally fine and totally valid, but by exposing internal messages we're now able to be more flexible and specific in our update functions if need be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants