From 51c1549540049a5cc83cbc7bb4c803af76e93094 Mon Sep 17 00:00:00 2001 From: pocke Date: Sat, 17 Jan 2015 17:55:34 +0900 Subject: [PATCH] Write README [ci skip] --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index ec0a834..5cd6029 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,46 @@ goevent =============== +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 +``` LICENSE