(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestOn(t *testing.T) { |
| 9 | type User struct { |
| 10 | name string |
| 11 | } |
| 12 | var u = &User{name: "lily"} |
| 13 | var u2 = &User{name: "lucy"} |
| 14 | |
| 15 | events.On("hello", func() { |
| 16 | t.Log("world") |
| 17 | }) |
| 18 | events.On("hello", func() { |
| 19 | t.Log("world2") |
| 20 | }) |
| 21 | events.OnKey("hello", u, func() { |
| 22 | t.Log("world3") |
| 23 | }) |
| 24 | events.OnKey("hello", u, func() { |
| 25 | t.Log("world4") |
| 26 | }) |
| 27 | events.Remove(u) |
| 28 | events.Remove(u2) |
| 29 | events.OnKey("hello2", nil, func() { |
| 30 | t.Log("world2") |
| 31 | }) |
| 32 | events.Notify("hello") |
| 33 | } |