mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
feat!: make Init return the model
This commit is contained in:
@@ -236,8 +236,8 @@ func (m Model) readDir(path string, showHidden bool) tea.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the file picker model.
|
// Init initializes the file picker model.
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() (Model, tea.Cmd) {
|
||||||
return m.readDir(m.CurrentDirectory, m.ShowHidden)
|
return m, m.readDir(m.CurrentDirectory, m.ShowHidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update handles user interactions within the file picker model.
|
// Update handles user interactions within the file picker model.
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ func (m Model) ID() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init starts the stopwatch.
|
// Init starts the stopwatch.
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() (Model, tea.Cmd) {
|
||||||
return m.Start()
|
return m, m.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start starts the stopwatch.
|
// Start starts the stopwatch.
|
||||||
|
|||||||
+2
-2
@@ -125,8 +125,8 @@ func (m Model) Timedout() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init starts the timer.
|
// Init starts the timer.
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() (Model, tea.Cmd) {
|
||||||
return m.tick()
|
return m, m.tick()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update handles the timer tick.
|
// Update handles the timer tick.
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ func (m *Model) setInitialValues() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init exists to satisfy the tea.Model interface for composability purposes.
|
// Init exists to satisfy the tea.Model interface for composability purposes.
|
||||||
func (m Model) Init() tea.Cmd {
|
func (m Model) Init() (Model, tea.Cmd) {
|
||||||
return nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AtTop returns whether or not the viewport is at the very top position.
|
// AtTop returns whether or not the viewport is at the very top position.
|
||||||
|
|||||||
Reference in New Issue
Block a user