diff --git a/README.md b/README.md index c1ebea8..8c60910 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,17 @@ func Run() { ### Using the structure method +**interface:** + +```go +// Listener interface +type Listener interface { + Handle(e Event) error +} +``` + +**example:** + > Implementation interface `event.Listener` ```go diff --git a/README_cn.md b/README_cn.md index 3dd1e60..a1e5484 100644 --- a/README_cn.md +++ b/README_cn.md @@ -65,7 +65,7 @@ func main() { ## 编写事件监听 -- 使用匿名函数 +### 使用匿名函数 ```go package mypgk @@ -87,7 +87,18 @@ func Run() { } ``` -- 使用结构体方法 +### 使用结构体方法 + +**interface:** + +```go +// Listener interface +type Listener interface { + Handle(e Event) error +} +``` + +**示例:** > 实现接口 `event.Listener` @@ -110,7 +121,7 @@ func (l *MyListener) Handle(e event.Event) error { } ``` -## 同时注册多个事件监听 +### 同时注册多个事件监听 **interface:** @@ -201,7 +212,7 @@ func (e *MyEvent) CustomData() string { } ``` -使用: +**使用:** ```go e := &MyEvent{customData: "hello"}