Update doesn't work via model method #474
Answered
by
muesli
andrewebdev
asked this question in
Q&A
-
I'm having an issue where I'm obviously doing something wrong, or misunderstanding something. See below: Snippet from update() case key.Matches(msg, keys.Next):
// m.focussed += 1 // This works
cmd = m.Next() // This does NOT work Snippet from my model interface func (m Model) Next() tea.Cmd {
if m.focussed < 2 {
m.focussed += 1
} else {
m.focussed = 0
}
return nil
} |
Beta Was this translation helpful? Give feedback.
Answered by
muesli
Oct 1, 2022
Replies: 1 comment 2 replies
-
func (m Model) Next() tea.Cmd {
...
} This function is working on a copy of your func (m *Model) Next() tea.Cmd {
...
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
andrewebdev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function is working on a copy of your
Model
. If you change it to a pointer receiver, it will correctly update: