add Stringer for AppData

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-03 14:04:08 -04:00 committed by Jakub
parent febde4aeba
commit b80307301e

View File

@ -1,13 +1,25 @@
package main package main
import ( import (
"fmt"
"strings"
"github.com/dannypsnl/redux/v2/rematch" "github.com/dannypsnl/redux/v2/rematch"
) )
type AppData struct { type AppData struct {
Node NodeInfo // info about current node Node *NodeInfo // info about current node
Peers []Peer // list of peers for the node Peers []Peer // list of peers for the node
Current int // currently selected peer Current int // currently selected peer
}
func (d AppData) String() string {
peers := make([]string, len(d.Peers))
for i, p := range d.Peers {
peers[i] = p.String()
}
return fmt.Sprintf("AppData{Node: %v, Current: %d, Peers: [%v]}",
d.Node, d.Current, strings.Join(peers, ","))
} }
type AppModel struct { type AppModel struct {
@ -16,7 +28,7 @@ type AppModel struct {
} }
func (m *AppModel) SetInfo(s AppData, node NodeInfo) AppData { func (m *AppModel) SetInfo(s AppData, node NodeInfo) AppData {
s.Node = node s.Node = &node
return s return s
} }