E2 is Event Emitter library in Swift.
- Swift 4.2
- iOS 8.0 or later
- Cartfile
github "keygx/E2"
or
github "keygx/E2" "branch-name"
or
github "keygx/E2" "tag"
- install
$ carthage update
To integrate "E2.framework" into your Xcode project
// define name
struct EventName {
static let Foo = E2.Name("e2_Foo")
}
// event handler
let handler = { (response: E2.Response) in
switch(response.result) {
case .success:
print("success:\n \(response.data)")
case .failure:
print("error:\n \(response.data)")
}
}
// add event
E2.add(queue: .main, name: EventName.Foo, handler: handler)
// callback success
E2.callback(E2.Response(result: .success, data: data), name: EventName.Foo)
// callback failure
E2.callback(E2.Response(result: .failure, data: error), name: EventName.Foo)
E2 is released under the MIT license. See LICENSE for details.
Yukihiko Kagiyama (keygx) https://twitter.com/keygx