Permalink
Browse files

add ability to reset a given bridge for reloading webviews

  • Loading branch information...
1 parent 77b5263 commit f3e90bf7dde48a5a3a6dd311d82eb681ebee6878 @marcuswestin committed Nov 16, 2012
@@ -14,6 +14,7 @@ typedef void (^WVJBHandler)(id data, WVJBResponse* response);
- (void)callHandler:(NSString*)handlerName;
- (void)callHandler:(NSString*)handlerName data:(id)data;
- (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
+- (void)reset;
@end
@interface WVJBResponse : NSObject
@@ -37,12 +37,10 @@ + (id)bridgeForWebView:(UIWebView *)webView handler:(WVJBHandler)handler {
+ (id)bridgeForWebView:(UIWebView *)webView webViewDelegate:(id<UIWebViewDelegate>)webViewDelegate handler:(WVJBHandler)messageHandler {
WebViewJavascriptBridge* bridge = [[WebViewJavascriptBridge alloc] init];
bridge.messageHandler = messageHandler;
- bridge.startupMessageQueue = [NSMutableArray array];
- bridge.responseCallbacks = [NSMutableDictionary dictionary];
- bridge.messageHandlers = [NSMutableDictionary dictionary];
- bridge.uniqueId = 0;
bridge.webView = webView;
bridge.webViewDelegate = webViewDelegate;
+ bridge.messageHandlers = [NSMutableDictionary dictionary];
+ [bridge reset];
webView.delegate = bridge;
return bridge;
}
@@ -74,6 +72,12 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler {
[self.messageHandlers setObject:handler forKey:handlerName];
}
+- (void)reset {
+ self.startupMessageQueue = [NSMutableArray array];
+ self.responseCallbacks = [NSMutableDictionary dictionary];
+ self.uniqueId = 0;
+}
+
- (void)_sendData:(NSDictionary *)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName {
NSMutableDictionary* message = [NSMutableDictionary dictionaryWithObject:data forKey:@"data"];

0 comments on commit f3e90bf

Please sign in to comment.