From 83541c1997c3d383b3d47e7785efa2338129b41d Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Tue, 9 Jun 2020 15:21:16 -0400 Subject: [PATCH 1/9] Setup handshake mechanism for gutenberg bridge --- gutenberg | 2 +- react-native-gutenberg-bridge/index.js | 4 ++ .../ios/Gutenberg.swift | 5 +++ .../ios/RNReactNativeGutenbergBridge.m | 1 + .../ios/RNReactNativeGutenbergBridge.swift | 45 +++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 8a6171f63d..1d53b3ab91 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 8a6171f63deee8994a3848ffa1481c0920769d8c +Subproject commit 1d53b3ab91a36482888b761e363356996d2228b3 diff --git a/react-native-gutenberg-bridge/index.js b/react-native-gutenberg-bridge/index.js index e52a1d0732..09ef46a731 100644 --- a/react-native-gutenberg-bridge/index.js +++ b/react-native-gutenberg-bridge/index.js @@ -83,6 +83,10 @@ export function subscribePreferredColorScheme( callback ) { return gutenbergBridgeEvents.addListener( 'preferredColorScheme', callback ); } +export function subscribeHandshake( callback ) { + return gutenbergBridgeEvents.addListener( 'handshake', callback ); +} + /** * @callback FnReplaceBlockCompletion * @param {string} html the HTML to replace the block. diff --git a/react-native-gutenberg-bridge/ios/Gutenberg.swift b/react-native-gutenberg-bridge/ios/Gutenberg.swift index 8b4c509804..9c0ce4f239 100644 --- a/react-native-gutenberg-bridge/ios/Gutenberg.swift +++ b/react-native-gutenberg-bridge/ios/Gutenberg.swift @@ -88,6 +88,11 @@ public class Gutenberg: NSObject { super.init() bridgeModule.dataSource = dataSource logThreshold = isPackagerRunning ? .trace : .error + + // This async call is here to mimic an event coming in before the editor is ready the timing seems to be a good point where some go through and some do not. + DispatchQueue.main.asyncAfter(wallDeadline: .now() + .milliseconds(600)) { + self.setTitle("🌉") + } } public func invalidate() { diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m index b8692ea0d0..2daa2e653d 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m @@ -23,5 +23,6 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject) RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter) RCT_EXTERN_METHOD(requestStarterPageTemplatesTooltipShown:(RCTResponseSenderBlock)callback) RCT_EXTERN_METHOD(setStarterPageTemplatesTooltipShown:(BOOL)tooltipShown) +RCT_EXTERN_METHOD(acknowledgeConnecton:(NSString *)token) @end diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index 30acfd3c1c..1089e15d67 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -1,9 +1,18 @@ +struct GutenbergEvent { + let name: String + let body: Any +} + @objc (RNReactNativeGutenbergBridge) public class RNReactNativeGutenbergBridge: RCTEventEmitter { weak var delegate: GutenbergBridgeDelegate? weak var dataSource: GutenbergBridgeDataSource? private var isJSLoading = true private var hasObservers = false + private var connectionEstablished = false + private let handshakeToken = UUID() + private var queuedEvents = [GutenbergEvent]() + private let queuedEventProcessQueue = DispatchQueue(label:"LockingQueue") // MARK: - Messaging methods @@ -188,6 +197,41 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } } + @objc + public func acknowledgeConnecton(_ token: String?) { + + guard !connectionEstablished else { return } // We have an established connection no need to trigger a new one. + guard let token = token, token == handshakeToken.uuidString else { + sendEvent(withName: RNReactNativeGutenbergBridge.EventName.handshake.rawValue, body: handshakeToken.uuidString) + return + } + + connectionEstablished = true + queuedEventProcessQueue.async { // replay the triggered events in order on a synchronized queue as the array is mutating + while (self.queuedEvents.count > 0) { + let event = self.queuedEvents.removeFirst() + self.sendEvent(withName: event.name, body: event.body) + } + } + } + + public override func sendEvent(withName name: String!, body: Any!) { + + if connectionEstablished { + super.sendEvent(withName: name, body: body) + } else { + let event = GutenbergEvent(name: name, body: body) + queueEvent(event) + super.sendEvent(withName: RNReactNativeGutenbergBridge.EventName.handshake.rawValue, body: handshakeToken.uuidString) + } + } + + func queueEvent(_ event:GutenbergEvent) { + queuedEventProcessQueue.async { // adding on a synchronized queue as the array might mutate by another process. + self.queuedEvents.append(event) + } + } + private func shouldLog(with level: Int) -> Bool { return level >= RCTGetLogThreshold().rawValue } @@ -267,6 +311,7 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { extension RNReactNativeGutenbergBridge { enum EventName: String, CaseIterable { + case handshake case requestGetHtml case setTitle case toggleHTMLMode From f4879900275bf91c0caab64c27cfdfe2bc2b9f0a Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Tue, 9 Jun 2020 16:22:45 -0400 Subject: [PATCH 2/9] Simplify handshake --- gutenberg | 2 +- react-native-gutenberg-bridge/index.js | 4 --- .../ios/Gutenberg.swift | 2 +- .../ios/RNReactNativeGutenbergBridge.m | 2 +- .../ios/RNReactNativeGutenbergBridge.swift | 25 ++++++------------- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/gutenberg b/gutenberg index 1d53b3ab91..bcb4e5d110 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 1d53b3ab91a36482888b761e363356996d2228b3 +Subproject commit bcb4e5d110530dba4a6bc427c1cba149263ddcc6 diff --git a/react-native-gutenberg-bridge/index.js b/react-native-gutenberg-bridge/index.js index 09ef46a731..e52a1d0732 100644 --- a/react-native-gutenberg-bridge/index.js +++ b/react-native-gutenberg-bridge/index.js @@ -83,10 +83,6 @@ export function subscribePreferredColorScheme( callback ) { return gutenbergBridgeEvents.addListener( 'preferredColorScheme', callback ); } -export function subscribeHandshake( callback ) { - return gutenbergBridgeEvents.addListener( 'handshake', callback ); -} - /** * @callback FnReplaceBlockCompletion * @param {string} html the HTML to replace the block. diff --git a/react-native-gutenberg-bridge/ios/Gutenberg.swift b/react-native-gutenberg-bridge/ios/Gutenberg.swift index 9c0ce4f239..031a4ee098 100644 --- a/react-native-gutenberg-bridge/ios/Gutenberg.swift +++ b/react-native-gutenberg-bridge/ios/Gutenberg.swift @@ -90,7 +90,7 @@ public class Gutenberg: NSObject { logThreshold = isPackagerRunning ? .trace : .error // This async call is here to mimic an event coming in before the editor is ready the timing seems to be a good point where some go through and some do not. - DispatchQueue.main.asyncAfter(wallDeadline: .now() + .milliseconds(600)) { + DispatchQueue.main.asyncAfter(wallDeadline: .now() + .milliseconds(1)) { self.setTitle("🌉") } } diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m index 2daa2e653d..d3fa59d26d 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m @@ -23,6 +23,6 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject) RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter) RCT_EXTERN_METHOD(requestStarterPageTemplatesTooltipShown:(RCTResponseSenderBlock)callback) RCT_EXTERN_METHOD(setStarterPageTemplatesTooltipShown:(BOOL)tooltipShown) -RCT_EXTERN_METHOD(acknowledgeConnecton:(NSString *)token) +RCT_EXTERN_METHOD(acknowledgeConnecton) @end diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index 1089e15d67..e5f82a4006 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -198,13 +198,9 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } @objc - public func acknowledgeConnecton(_ token: String?) { + public func acknowledgeConnecton() { guard !connectionEstablished else { return } // We have an established connection no need to trigger a new one. - guard let token = token, token == handshakeToken.uuidString else { - sendEvent(withName: RNReactNativeGutenbergBridge.EventName.handshake.rawValue, body: handshakeToken.uuidString) - return - } connectionEstablished = true queuedEventProcessQueue.async { // replay the triggered events in order on a synchronized queue as the array is mutating @@ -217,18 +213,13 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { public override func sendEvent(withName name: String!, body: Any!) { - if connectionEstablished { - super.sendEvent(withName: name, body: body) - } else { - let event = GutenbergEvent(name: name, body: body) - queueEvent(event) - super.sendEvent(withName: RNReactNativeGutenbergBridge.EventName.handshake.rawValue, body: handshakeToken.uuidString) - } - } - - func queueEvent(_ event:GutenbergEvent) { - queuedEventProcessQueue.async { // adding on a synchronized queue as the array might mutate by another process. - self.queuedEvents.append(event) + queuedEventProcessQueue.async { // checking on a synchronized queue as the array might mutate by another process. + if self.connectionEstablished && self.queuedEvents.count == 0 { + super.sendEvent(withName: name, body: body) + } else { + let event = GutenbergEvent(name: name, body: body) + self.queuedEvents.append(event) + } } } From e01ea90e87bfcabfb75aab800f530aa7dba30bb3 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Wed, 10 Jun 2020 10:28:54 -0400 Subject: [PATCH 3/9] Adjust call for replaying events to call super to avoid the custom logic on the instance --- .../ios/RNReactNativeGutenbergBridge.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index e5f82a4006..a334547ff3 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -199,14 +199,12 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { @objc public func acknowledgeConnecton() { - - guard !connectionEstablished else { return } // We have an established connection no need to trigger a new one. - + guard !connectionEstablished else { return } // We have an established connection no need to continue. connectionEstablished = true - queuedEventProcessQueue.async { // replay the triggered events in order on a synchronized queue as the array is mutating + queuedEventProcessQueue.async { // replay the triggered events in order on a synchronized queue as the array is mutating. while (self.queuedEvents.count > 0) { let event = self.queuedEvents.removeFirst() - self.sendEvent(withName: event.name, body: event.body) + super.sendEvent(withName: event.name, body: event.body) // execute this on super as we want to avoid logic in self. } } } From 880478c0c915a6eaf8348944c367623f48945eb5 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Wed, 10 Jun 2020 11:16:48 -0400 Subject: [PATCH 4/9] Revert unneeded changes and remove mocked event --- gutenberg | 2 +- react-native-gutenberg-bridge/ios/Gutenberg.swift | 5 ----- .../ios/RNReactNativeGutenbergBridge.swift | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/gutenberg b/gutenberg index bcb4e5d110..103041270e 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit bcb4e5d110530dba4a6bc427c1cba149263ddcc6 +Subproject commit 103041270e5a237dd9b25f6d527a07656fb27832 diff --git a/react-native-gutenberg-bridge/ios/Gutenberg.swift b/react-native-gutenberg-bridge/ios/Gutenberg.swift index 031a4ee098..8b4c509804 100644 --- a/react-native-gutenberg-bridge/ios/Gutenberg.swift +++ b/react-native-gutenberg-bridge/ios/Gutenberg.swift @@ -88,11 +88,6 @@ public class Gutenberg: NSObject { super.init() bridgeModule.dataSource = dataSource logThreshold = isPackagerRunning ? .trace : .error - - // This async call is here to mimic an event coming in before the editor is ready the timing seems to be a good point where some go through and some do not. - DispatchQueue.main.asyncAfter(wallDeadline: .now() + .milliseconds(1)) { - self.setTitle("🌉") - } } public func invalidate() { diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index a334547ff3..bbbdff031e 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -10,7 +10,6 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { private var isJSLoading = true private var hasObservers = false private var connectionEstablished = false - private let handshakeToken = UUID() private var queuedEvents = [GutenbergEvent]() private let queuedEventProcessQueue = DispatchQueue(label:"LockingQueue") @@ -300,7 +299,6 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { extension RNReactNativeGutenbergBridge { enum EventName: String, CaseIterable { - case handshake case requestGetHtml case setTitle case toggleHTMLMode From 04e30383bb91f2ca8550107ba179d04630d8d918 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 12 Jun 2020 15:12:11 -0400 Subject: [PATCH 5/9] Adjust threading and method for queue --- gutenberg | 2 +- .../ios/Gutenberg.swift | 4 +- .../ios/RNReactNativeGutenbergBridge.m | 1 - .../ios/RNReactNativeGutenbergBridge.swift | 44 ++++++++----------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gutenberg b/gutenberg index 103041270e..84df4bd608 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 103041270e5a237dd9b25f6d527a07656fb27832 +Subproject commit 84df4bd6082e7793a2befddb2a652cb42f445d21 diff --git a/react-native-gutenberg-bridge/ios/Gutenberg.swift b/react-native-gutenberg-bridge/ios/Gutenberg.swift index 8b4c509804..7a3fa9a0fc 100644 --- a/react-native-gutenberg-bridge/ios/Gutenberg.swift +++ b/react-native-gutenberg-bridge/ios/Gutenberg.swift @@ -126,7 +126,7 @@ public class Gutenberg: NSObject { if let serverID = serverID { data["mediaServerId"] = serverID } - bridgeModule.sendEventIfNeeded(.mediaUpload, body: data) + sendEvent(.mediaUpload, body: data) } public func appendMedia(id: Int32, url: URL, type: MediaType) { @@ -135,7 +135,7 @@ public class Gutenberg: NSObject { "mediaUrl" : url.absoluteString, "mediaType": type.rawValue, ] - bridgeModule.sendEventIfNeeded(.mediaAppend, body: data) + sendEvent(.mediaAppend, body: data) } public func setFocusOnTitle() { diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m index d3fa59d26d..b8692ea0d0 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m @@ -23,6 +23,5 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject) RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter) RCT_EXTERN_METHOD(requestStarterPageTemplatesTooltipShown:(RCTResponseSenderBlock)callback) RCT_EXTERN_METHOD(setStarterPageTemplatesTooltipShown:(BOOL)tooltipShown) -RCT_EXTERN_METHOD(acknowledgeConnecton) @end diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index bbbdff031e..58ae190df9 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -9,10 +9,16 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { weak var dataSource: GutenbergBridgeDataSource? private var isJSLoading = true private var hasObservers = false - private var connectionEstablished = false private var queuedEvents = [GutenbergEvent]() - private let queuedEventProcessQueue = DispatchQueue(label:"LockingQueue") + public override init() { + super.init() + NotificationCenter.default.addObserver(forName: Notification.Name("RCTContentDidAppearNotification"), object: nil, queue: nil) { (_) in + DispatchQueue.main.async { + self.connectionEstablished() + } + } + } // MARK: - Messaging methods @objc @@ -95,7 +101,9 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { @objc func mediaUploadSync() { DispatchQueue.main.async { - self.delegate?.gutenbergDidRequestMediaUploadSync() + if self.hasObservers { + self.delegate?.gutenbergDidRequestMediaUploadSync() + } } } @@ -196,22 +204,18 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } } - @objc - public func acknowledgeConnecton() { - guard !connectionEstablished else { return } // We have an established connection no need to continue. - connectionEstablished = true - queuedEventProcessQueue.async { // replay the triggered events in order on a synchronized queue as the array is mutating. - while (self.queuedEvents.count > 0) { - let event = self.queuedEvents.removeFirst() - super.sendEvent(withName: event.name, body: event.body) // execute this on super as we want to avoid logic in self. - } + public func connectionEstablished() { + guard !hasObservers else { return } // We have an established connection no need to continue. + hasObservers = true + while (self.queuedEvents.count > 0) { + let event = self.queuedEvents.removeFirst() + super.sendEvent(withName: event.name, body: event.body) // execute this on super as we want to avoid logic in self. } } public override func sendEvent(withName name: String!, body: Any!) { - - queuedEventProcessQueue.async { // checking on a synchronized queue as the array might mutate by another process. - if self.connectionEstablished && self.queuedEvents.count == 0 { + DispatchQueue.main.async { + if self.hasObservers && self.queuedEvents.count == 0 { super.sendEvent(withName: name, body: body) } else { let event = GutenbergEvent(name: name, body: body) @@ -224,16 +228,6 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { return level >= RCTGetLogThreshold().rawValue } - override public func startObserving() { - super.startObserving() - hasObservers = true - } - - override public func stopObserving() { - super.stopObserving() - hasObservers = false - } - @objc func editorDidAutosave() { DispatchQueue.main.async { From 85c1770f388cf7d19174127a1858495cb2cb416d Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 12 Jun 2020 15:20:00 -0400 Subject: [PATCH 6/9] Revert gutenberg change --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 84df4bd608..8a6171f63d 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 84df4bd6082e7793a2befddb2a652cb42f445d21 +Subproject commit 8a6171f63deee8994a3848ffa1481c0920769d8c From fb8dad5a664b7e6850bc5314acbfa39fafe3607e Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Mon, 15 Jun 2020 09:58:20 -0400 Subject: [PATCH 7/9] Bump gutenberg version --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 8a6171f63d..b950684e9b 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 8a6171f63deee8994a3848ffa1481c0920769d8c +Subproject commit b950684e9b482a6fca786ba0666d6e2842c3aaca From 7f1bc5a0a299886501c11488bf2901a094862a7b Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Tue, 16 Jun 2020 08:34:52 -0400 Subject: [PATCH 8/9] Adjust notification name to use existing extensions --- .../ios/RNReactNativeGutenbergBridge.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index 58ae190df9..35e96870b9 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -13,7 +13,7 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { public override init() { super.init() - NotificationCenter.default.addObserver(forName: Notification.Name("RCTContentDidAppearNotification"), object: nil, queue: nil) { (_) in + NotificationCenter.default.addObserver(forName: .RCTContentDidAppear, object: nil, queue: nil) { (_) in DispatchQueue.main.async { self.connectionEstablished() } From 8f13252ea1940ea529b3790e9e75946ac16f2674 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Wed, 17 Jun 2020 12:43:05 -0400 Subject: [PATCH 9/9] Adjust optionality --- .../ios/RNReactNativeGutenbergBridge.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift index ed1dbc997d..aead5bf2cb 100644 --- a/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift +++ b/react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift @@ -1,6 +1,6 @@ struct GutenbergEvent { let name: String - let body: Any + let body: Any? } @objc (RNReactNativeGutenbergBridge) @@ -214,7 +214,7 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter { } } - public override func sendEvent(withName name: String!, body: Any!) { + public override func sendEvent(withName name: String, body: Any?) { DispatchQueue.main.async { if self.hasObservers && self.queuedEvents.count == 0 { super.sendEvent(withName: name, body: body)