Skip to content
Myr

Refactor subscription implementation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

There was a bug in the previous implementation where it didn't allow for more than one subscription.

authored by Christian Rocha · committed by Christian Rocha · parent b6c8792 · Browse files · 1 file+13 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−22 removed

  • other:+13 added−22 removed

1 file+13 added−22 removed

modified:tea.go+13 added-22 removed
97 unmodified lines
98 }99 }100 }()101102 // Process subscriptions103 go func() {104 if len(p.subscriptions) > 0 {105 for _, sub := range p.subscriptions {106 go func(s Sub) {107 for {108 msgs <- s(p.model)109 }110 }(sub)111 }112 }113 }()114115 // Process commands116 go func() {117 for {118 select {
8 unmodified lines
127 }128 }129 }()130118 // Subscriptions. Subscribe to user input.119 // TODO: should the blocking `for` be here, or in the end-user portion120 // of the program?121 go func() {122 select {123 case <-done:124 return125 default:126 if len(p.subscriptions) > 0 {127 for _, sub := range p.subscriptions {128 if sub != nil {129 go func() {130 for {131 msgs <- sub(p.model)132 }133 }()134 }135 }136 }137 }138 }()139131 // Handle updates and draw132 for {133 select {134 case msg := <-msgs:
54 unmodified lines