UNPKG

880 BPlain TextView Raw
1//Copyright (c) 2019 ___ORGANIZATIONNAME___. All rights reserved.
2
3import Foundation
4
5class EventEmitter {
6
7 /// Shared Instance.
8 public static var sharedInstance = EventEmitter()
9
10 // ReactNativeEventEmitter is instantiated by React Native with the bridge.
11 private var eventEmitter: ReactNativeEventEmitter!
12
13 private init() {}
14
15 // When React Native instantiates the emitter it is registered here.
16 func registerEventEmitter(eventEmitter: ReactNativeEventEmitter) {
17 self.eventEmitter = eventEmitter
18 }
19
20 func dispatch(name: String, body: Any?) {
21 eventEmitter.sendEvent(withName: name, body: body)
22 }
23
24 /// All Events which must be support by React Native.
25 lazy var allEvents: [String] = {
26 var allEventNames: [String] = [
27 "onSignInStateChanged"
28 ]
29
30 return allEventNames
31 }()
32
33}