From de8b2adbcc4a39c359f3dd30249ac4ee225d4b9c Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 16 Aug 2022 13:41:12 +0200 Subject: Refactor: Use an interface for the data in the FSM callback --- internal/fsm/fsm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/fsm') diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 84c39d5..3c51ce7 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -124,12 +124,12 @@ type FSM struct { // Info to be passed from the parent state Name string - StateCallback func(FSMStateID, FSMStateID, string) + StateCallback func(FSMStateID, FSMStateID, interface{}) Directory string Debug bool } -func (fsm *FSM) Init(name string, callback func(FSMStateID, FSMStateID, string), directory string, debug bool) { +func (fsm *FSM) Init(name string, callback func(FSMStateID, FSMStateID, interface{}), directory string, debug bool) { fsm.States = FSMStates{ DEREGISTERED: FSMState{Transitions: []FSMTransition{{NO_SERVER, "Client registers"}}}, NO_SERVER: FSMState{Transitions: []FSMTransition{{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}, {CONNECTED, "The user is already connected"}, {ASK_LOCATION, "Change the location in the main screen"}}}, @@ -191,7 +191,7 @@ func (fsm *FSM) GoBack() { fsm.GoTransition(fsm.States[fsm.Current].BackState) } -func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string, background bool) bool { +func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data interface{}, background bool) bool { ok := fsm.HasTransition(newState) if ok { -- cgit v1.2.3