event

package
v0.0.0-...-f84f93e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

简单的事件派发类,支持线程安全,注意:不能嵌套监听和派发事件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Dispatcher) Dispatch

func (this *Dispatcher) Dispatch(eventtype string, args interface{})

派发自定义类型事件,附带一个参数

func (*Dispatcher) Listen

func (this *Dispatcher) Listen(eventtype string, hander Handler)

监听事件

func (*Dispatcher) ListenOnce

func (this *Dispatcher) ListenOnce(eventtype string, hander Handler)

监听一次指定类型事件, 接受完事件移除监听

func (*Dispatcher) RemoveAll

func (this *Dispatcher) RemoveAll()

type Handler

type Handler func(string, interface{})

type IDispath

type IDispath interface {
	Dispatch(eventtype string, args interface{})
	Listen(eventtype string, hander Handler)
	ListenOnce(eventtype string, hander Handler)
	RemoveAll()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL