Skip to content

jackc/signal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Signal

Signal is a Go implementation of the signal pattern. It was inspired by js-signals. It uses gen to generate type safe signal types.

Usage

See demo/main.go for a simple example. See demo/event_signal.go for and example of the generated signal type.

To add to your project:

$ gen add github.com/jackc/signal

Add the type annotation to the type you wish to signal with:

// +gen signal
type Event struct {
  ID   int
  Type string
}

Generate the type:

$ gen

You will now have the file event_signal.go containing type EventSignal has Add, Remove, and Dispatch methods.

About

Typed signals with gen for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages