Skip to content

Events ability to halt#338

Open
larrycinnabar wants to merge 1 commit intoaarondl:masterfrom
AaHaInc:feature/events-halt
Open

Events ability to halt#338
larrycinnabar wants to merge 1 commit intoaarondl:masterfrom
AaHaInc:feature/events-halt

Conversation

@larrycinnabar
Copy link
Copy Markdown

Problem:

We can't halt event loop from an event inside (stop other hooks to be executed)

Fixes #337

Idea of solution is to return a custom ErrHalt that will be considered to stop immediately the loop

Copy link
Copy Markdown

@fgm fgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can avoid a dependency.

Comment thread events.go

import (
"fmt"
"github.com/friendsofgo/errors"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use "errors" ? It has been including errors.Is since Go 1.13.

Comment thread events.go
// Event type is for describing events
type Event int

var ErrHalt = fmt.Errorf("event halt")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No param so probably just use errors.New ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to stop EventLoop from inside an event

2 participants