Skip to content

Commit

Permalink
Merge pull request #180 from gustavosbarreto/report_current_state_aft…
Browse files Browse the repository at this point in the history
…er_enter_cb

updatehub: report current state after enter callback
  • Loading branch information
otavio committed Nov 23, 2017
2 parents 99f007f + dc9f162 commit ccb46cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions updatehub/updatehub.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ func (uh *UpdateHub) ProcessCurrentState() State {

var err error

uh.ReportCurrentState()

// this must be done after the report, because the report uses it
uh.previousState = uh.state
defer func() {
uh.previousState = uh.state
}()

es, isErrorState := uh.state.(*ErrorState)
if isErrorState {
Expand All @@ -237,6 +237,8 @@ func (uh *UpdateHub) ProcessCurrentState() State {
log.Warn(err)
}

uh.ReportCurrentState()

state, _ := uh.state.Handle(uh)
uh.state = state
} else {
Expand All @@ -252,6 +254,8 @@ func (uh *UpdateHub) ProcessCurrentState() State {
return uh.state
}

uh.ReportCurrentState()

state, cancel := uh.state.Handle(uh)

flow, err = uh.stateChangeCallback(uh.state, "leave")
Expand Down

0 comments on commit ccb46cf

Please sign in to comment.