diff --git a/Roadmap.md b/Roadmap.md index 56e7c2f5..b5eed90e 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -30,7 +30,7 @@ Misc - [ ] Style consistency through all code - [ ] Test pod - [ ] Fix OSX lint warnings (`pod spec lint`) -- [ ] I believe `receiveMessageQueue` in JS is no longer needed, since the JS explicitly tells ObjC when to start sending messages. Remove? +- [X] I believe `receiveMessageQueue` in JS is no longer needed, since the JS explicitly tells ObjC when to start sending messages. Remove? v5.0.1 ------ diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index bbf23c60..cfe20229 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -111,15 +111,12 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ - (void)injectJavascriptFile { NSString *js = WebViewJavascriptBridge_js(); [self _evaluateJavascript:js]; - [self _dispatchStartUpMessageQueue]; -} - -- (void)_dispatchStartUpMessageQueue { if (self.startupMessageQueue) { - for (id queuedMessage in self.startupMessageQueue) { + NSArray* queue = self.startupMessageQueue; + self.startupMessageQueue = nil; + for (id queuedMessage in queue) { [self _dispatchMessage:queuedMessage]; } - self.startupMessageQueue = nil; } } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 03379d5a..6756c878 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -28,7 +28,6 @@ var messagingIframe; var sendMessageQueue = []; - var receiveMessageQueue = []; var messageHandlers = {}; var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; @@ -95,11 +94,7 @@ function _dispatchMessageFromObjC(messageJSON) { } function _handleMessageFromObjC(messageJSON) { - if (receiveMessageQueue) { - receiveMessageQueue.push(messageJSON); - } else { - _dispatchMessageFromObjC(messageJSON); - } + _dispatchMessageFromObjC(messageJSON); } messagingIframe = document.createElement('iframe'); @@ -107,12 +102,6 @@ function _handleMessageFromObjC(messageJSON) { messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; document.documentElement.appendChild(messagingIframe); - var receivedMessages = receiveMessageQueue; - receiveMessageQueue = null; - for (var i=0; i