迅捷事件
不带参数的事件示例:
var event = Event ()
event. on () {
print ( " regular listener " )
}
event. once () {
print ( " one time listener " )
}
event. emit ()
event. emit ()
有一个论点:
var counter = 0
var event = EventWith ()
event. on () {
counter += $0
}
event. once () {
counter += $0
}
event. emitWith ( 1 )
有两个论点:
var counter = 0
var string = ''
var event = EventDue < Int , Str
2021-07-07 21:03:20
3KB
Swift
1