pocke.goevent/README.md

57 lines
1.0 KiB
Markdown
Raw Normal View History

2015-01-11 13:24:14 +08:00
[![Build Status](https://travis-ci.org/pocke/goevent.svg?branch=master)](https://travis-ci.org/pocke/goevent)
[![Coverage Status](https://img.shields.io/coveralls/pocke/goevent.svg)](https://coveralls.io/r/pocke/goevent)
[![GoDoc](https://godoc.org/github.com/pocke/goevent?status.svg)](https://godoc.org/github.com/pocke/goevent)
2015-01-07 21:44:35 +08:00
2015-01-11 13:24:14 +08:00
goevent
2015-01-07 21:44:35 +08:00
===============
2015-01-17 16:55:34 +08:00
goevent is event dispatcher written by golang.
example
===========
listen for event
-----------------
```go
e := goevent.New()
e.On(func(i int, s string){
fmt.Printf("%d: %s\n", i, s)
})
```
Trigger
----------
```go
e.Trigger(1, "foo")
```
Use event table
----------------
```go
table := goevent.NewTable()
table.On("foo", func(i int){
fmt.Printf("foo: %d\n", i)
})
table.On("bar", func(s string){
fmt.Printf("bar: %s\n", s)
})
table.Trigger("foo", 1)
table.Trigger("bar", "hoge")
table.Trigger("bar", 38) // retrun error
```
2015-01-07 21:44:35 +08:00
LICENSE
-----------
Copyright © 2015 pocke
Licensed [MIT][mit]
[MIT]: http://www.opensource.org/licenses/mit-license.php