Add emitter so I can now send events to the RN core
This commit is contained in:
parent
4e4a92c2a3
commit
7177b9e927
7 changed files with 111 additions and 14 deletions
32
ios/Native/Application/Shared/Emitter/Emitter.swift
Normal file
32
ios/Native/Application/Shared/Emitter/Emitter.swift
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Emitter.swift
|
||||
// RNPlayground
|
||||
//
|
||||
// Created by Artur Gurgul on 02/08/2025.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import React
|
||||
//import React_RCTAppDelegate
|
||||
//import ReactAppDependencyProvider
|
||||
|
||||
@objc(Emitter)
|
||||
class Emitter: RCTEventEmitter {
|
||||
override static func requiresMainQueueSetup() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
EventEmitter.sharedInstance.register(eventEmitter: self)
|
||||
|
||||
}
|
||||
|
||||
override func supportedEvents() -> [String]! {
|
||||
return ["onMessage"]
|
||||
}
|
||||
|
||||
@objc func send(message: String) {
|
||||
sendEvent(withName: "onMessage", body: ["message": message])
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue