Documentation ¶
Overview ¶
Package event exposes a single exported `Context` type that may be used to influence the execution flow of events that occur on a server. Generally, the caller of `event.C()` calls `Context.Stop()` or `Context.Continue()` to call a function when an event is or is not cancelled respectively. Such events may be cancelled by passing the created `Context` to the end user, who is then able to cancel it by calling `Context.Cancel()`. Additionally, a `Context.After()` function is exported, which may be used to call code after the `Context.Stop()` and `Context.Continue()` functions are called. Code performing the event should be run in these functions, so that the `Context.After()` function is able to run code of the end user immediately after the event itself happens.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents the context of an event. Handlers of an event may call methods on the context to change the result of the event.
func (*Context) After ¶
After calls the function passed after the action of the event has been completed, either by a call to (*Context).Continue() or (*Context).Stop(). After can be executed multiple times to attach more functions to be called after the event is executed.
func (*Context) Continue ¶
func (ctx *Context) Continue(f func())
Continue calls the function f if the context is not cancelled. If it is cancelled, Continue will return immediately. These functions are not generally useful for handling events. See After() for executing code after the event happens.
func (*Context) Stop ¶
func (ctx *Context) Stop(f func())
Stop calls the function f if the context is cancelled. If it is not cancelled, Stop will return immediately. Stop does the opposite of Continue. These functions are not generally useful for handling events. See After() for executing code after the event happens.