Skip to content

Conversation

larrycinnabar
Copy link

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

@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.


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

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.

// Event type is for describing events
type Event int

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

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