Skip to content

Commit

Permalink
event: make EventClient a parameter of Subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Aug 31, 2024
1 parent 82603a4 commit 2911f0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *EventClient) Receive() ([]ReceivedData, error) {
// Subscribe to events.
// You need to pass an implementation of [EventHandler] interface for each of
// the events you want to handle and all event types you want to handle.
func (c *EventClient) Subscribe(ev EventHandler, events ...EventType) error {
func Subscribe(c *EventClient, ev EventHandler, events ...EventType) error {
for {
msg, err := c.Receive()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions event/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func (f *FakeEventClient) Receive() ([]ReceivedData, error) {
}

func TestSubscribe(t *testing.T) {
err := c.SubscribeWithoutLoop(h, GetAllEvents()...)
err := SubscribeWithoutLoop(*c, h, GetAllEvents()...)
if err != nil {
t.Error(err)
}
}

func (c *FakeEventClient) SubscribeWithoutLoop(ev EventHandler, events ...EventType) error {
func SubscribeWithoutLoop(c FakeEventClient, ev EventHandler, events ...EventType) error {
msg, err := c.Receive()
if err != nil {
return err
Expand Down

0 comments on commit 2911f0f

Please sign in to comment.