Skip to content

Commit

Permalink
Remove receiveMessageQueue, since it is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Jan 29, 2016
1 parent ad1daba commit 0ce4dbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------
Expand Down
9 changes: 3 additions & 6 deletions WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
13 changes: 1 addition & 12 deletions WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

var messagingIframe;
var sendMessageQueue = [];
var receiveMessageQueue = [];
var messageHandlers = {};

var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme';
Expand Down Expand Up @@ -95,24 +94,14 @@ function _dispatchMessageFromObjC(messageJSON) {
}

function _handleMessageFromObjC(messageJSON) {
if (receiveMessageQueue) {
receiveMessageQueue.push(messageJSON);
} else {
_dispatchMessageFromObjC(messageJSON);
}
_dispatchMessageFromObjC(messageJSON);
}

messagingIframe = document.createElement('iframe');
messagingIframe.style.display = 'none';
messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE;
document.documentElement.appendChild(messagingIframe);

var receivedMessages = receiveMessageQueue;
receiveMessageQueue = null;
for (var i=0; i<receivedMessages.length; i++) {
_dispatchMessageFromObjC(receivedMessages[i]);
}

setTimeout(_callWVJBCallbacks, 0);
function _callWVJBCallbacks() {
var callbacks = window.WVJBCallbacks;
Expand Down

0 comments on commit 0ce4dbc

Please sign in to comment.