package ui import "opslag.de/schobers/zntg" type EventFn func(Context) type EventStateFn func(Context, interface{}) type EventArgs struct { Context Context State interface{} } type Events struct { zntg.Events } type EventHandler interface { AddHandler(EventStateFn) uint AddHandlerEmpty(EventFn) uint RemoveHandler(uint) } func (e *Events) Notify(ctx Context, state interface{}) bool { return e.Events.Notify(EventArgs{Context: ctx, State: state}) } func (e *Events) AddHandler(handler EventStateFn) uint { return e.Events.AddHandler(func(state interface{}) { args := state.(EventArgs) handler(args.Context, args.State) }) } func (e *Events) AddHandlerEmpty(handler EventFn) uint { return e.AddHandler(func(ctx Context, _ interface{}) { handler(ctx) }) }