Skip to content
Discussion options

You must be logged in to vote

$(cat <<'ENDOFBODY'
Ran into a similar setup before. Here's how I'd structure this:

Your top-level model owns a slice of progress bars and a log buffer. Each download is its own progressModel that sends messages back to the parent when it updates.

type model struct {
    bars   []progressModel
    logs   []string
    width  int
}

type progressModel struct {
    id       int
    name     string
    progress float64
    done     bool
}

What actually makes this work is a custom message type for progress updates. Each download goroutine sends these back through p.Send():

type progressMsg struct {
    id       int
    progress float64
}

type logMsg struct {
    text string
}

func runDownload(

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by solvingj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants