Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds stopLoading method #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/RCTWebViewBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
- (void)goForward;
- (void)goBack;
- (void)reload;
- (void)stopLoading;
- (void)sendToBridge:(NSString *)message;

@end
4 changes: 4 additions & 0 deletions ios/RCTWebViewBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ - (void)reload
[_webView reload];
}

-(void)stopLoading {
[_webView stopLoading];
}

- (void)sendToBridge:(NSString *)message
{
//we are warpping the send message in a function to make sure that if
Expand Down
12 changes: 12 additions & 0 deletions ios/RCTWebViewBridgeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ - (UIView *)view
}];
}

RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebViewBridge *> *viewRegistry) {
RCTWebViewBridge *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWebViewBridge class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWebViewBridge, got: %@", view);
} else {
[view stopLoading];
}
}];
}

RCT_EXPORT_METHOD(sendToBridge:(nonnull NSNumber *)reactTag
value:(NSString*)message)
{
Expand Down
8 changes: 8 additions & 0 deletions webview-bridge/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ var WebViewBridge = React.createClass({
);
},

stopLoading: function() {
UIManager.dispatchViewManagerCommand(
this.getWebViewBridgeHandle(),
UIManager.RCTWebViewBridge.Commands.stopLoading,
null
);
},

sendToBridge: function (message: string) {
WebViewBridgeManager.sendToBridge(this.getWebViewBridgeHandle(), message);
},
Expand Down