Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 15, 2021
1 parent 383905c commit 473ac8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {

## 编写事件监听

- 使用匿名函数
### 使用匿名函数

```go
package mypgk
Expand All @@ -87,7 +87,18 @@ func Run() {
}
```

- 使用结构体方法
### 使用结构体方法

**interface:**

```go
// Listener interface
type Listener interface {
Handle(e Event) error
}
```

**示例:**

> 实现接口 `event.Listener`
Expand All @@ -110,7 +121,7 @@ func (l *MyListener) Handle(e event.Event) error {
}
```

## 同时注册多个事件监听
### 同时注册多个事件监听

**interface:**

Expand Down Expand Up @@ -201,7 +212,7 @@ func (e *MyEvent) CustomData() string {
}
```

使用:
**使用:**

```go
e := &MyEvent{customData: "hello"}
Expand Down

0 comments on commit 473ac8a

Please sign in to comment.