Skip to content

Commit

Permalink
docs: add docstrings to public model methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Dec 8, 2022
1 parent 72941ca commit b3b63bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ignite/cmd/model/chain_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ type ChainDebug struct {
model cliuimodel.Events
}

// Init is the first function that will be called.
// It returns a batch command that listen events and also runs the debug server.
func (m ChainDebug) Init() tea.Cmd {
return tea.Batch(m.model.WaitEvent, m.cmd)
}

// Update is called when a message is received.
// It handles messages and executes the logic that updates the model.
func (m ChainDebug) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case cliuimodel.QuitMsg:
Expand All @@ -63,6 +67,7 @@ func (m ChainDebug) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.updateModel(msg)
}

// View renders the UI after every update.
func (m ChainDebug) View() string {
if m.error != nil {
// Make sure that the error is displayed in the same way
Expand Down
5 changes: 5 additions & 0 deletions ignite/cmd/model/chain_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ type ChainServe struct {
quitModel cliuimodel.Events
}

// Init is the first function that will be called.
// It returns a batch command that listen events and also runs the blockchain app.
func (m ChainServe) Init() tea.Cmd {
// On initialization wait for status events and start serving the blockchain
return tea.Batch(m.startModel.WaitEvent, m.cmd)
}

// Update is called when a message is received.
// It handles messages and executes the logic that updates the model.
func (m ChainServe) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if checkQuitKeyMsg(msg) {
m.state = stateChainServeQuitting
Expand All @@ -95,6 +99,7 @@ func (m ChainServe) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}

// View renders the UI after every update.
func (m ChainServe) View() string {
if m.error != nil {
return fmt.Sprintf("%s %s\n", icons.NotOK, colors.Error(m.error.Error()))
Expand Down

0 comments on commit b3b63bd

Please sign in to comment.