From 8972b56c9dde78ff35c8b6f1c142d0eae62765de Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 10 Sep 2024 14:04:36 -0400 Subject: [PATCH] feat!: make Init return the model --- filepicker/filepicker.go | 4 ++-- stopwatch/stopwatch.go | 4 ++-- timer/timer.go | 4 ++-- viewport/viewport.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/filepicker/filepicker.go b/filepicker/filepicker.go index 6f5fe06..b8a36cd 100644 --- a/filepicker/filepicker.go +++ b/filepicker/filepicker.go @@ -236,8 +236,8 @@ func (m Model) readDir(path string, showHidden bool) tea.Cmd { } // Init initializes the file picker model. -func (m Model) Init() tea.Cmd { - return m.readDir(m.CurrentDirectory, m.ShowHidden) +func (m Model) Init() (Model, tea.Cmd) { + return m, m.readDir(m.CurrentDirectory, m.ShowHidden) } // Update handles user interactions within the file picker model. diff --git a/stopwatch/stopwatch.go b/stopwatch/stopwatch.go index 6b298f7..8235661 100644 --- a/stopwatch/stopwatch.go +++ b/stopwatch/stopwatch.go @@ -73,8 +73,8 @@ func (m Model) ID() int { } // Init starts the stopwatch. -func (m Model) Init() tea.Cmd { - return m.Start() +func (m Model) Init() (Model, tea.Cmd) { + return m, m.Start() } // Start starts the stopwatch. diff --git a/timer/timer.go b/timer/timer.go index eb085e0..b9e7634 100644 --- a/timer/timer.go +++ b/timer/timer.go @@ -125,8 +125,8 @@ func (m Model) Timedout() bool { } // Init starts the timer. -func (m Model) Init() tea.Cmd { - return m.tick() +func (m Model) Init() (Model, tea.Cmd) { + return m, m.tick() } // Update handles the timer tick. diff --git a/viewport/viewport.go b/viewport/viewport.go index cb026c7..a871842 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -64,8 +64,8 @@ func (m *Model) setInitialValues() { } // Init exists to satisfy the tea.Model interface for composability purposes. -func (m Model) Init() tea.Cmd { - return nil +func (m Model) Init() (Model, tea.Cmd) { + return m, nil } // AtTop returns whether or not the viewport is at the very top position.