Skip to content

Commit c82cd78

Browse files
committed
Add onFileDownload
1 parent af9fb73 commit c82cd78

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,14 @@ Specifies function to be invoked when the WebView content process is terminated.
615615
/>
616616
```
617617

618+
#### `onFileDownload: WebViewDownloadEvent.t => unit`
619+
620+
_iOS only_
621+
622+
Specifies function to be invoked when the `WebView` is about to download a file.
623+
624+
<https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#onFileDownload>
625+
618626
#### `onError: WebViewErrorEvent.t => unit`
619627

620628
Specifies function to be invoked when the `WebView` fails to load.

src/ReactNativeWebView.bs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ var Source = {};
88

99
Event$ReactNative.SyntheticEvent({});
1010

11+
var WebViewDownloadEvent = {};
12+
13+
Event$ReactNative.SyntheticEvent({});
14+
1115
var WebViewErrorEvent = {};
1216

1317
Event$ReactNative.SyntheticEvent({});
@@ -42,6 +46,7 @@ exports.Source = Source;
4246
exports.DataDetectorTypes = DataDetectorTypes;
4347
exports.DecelerationRate = DecelerationRate;
4448
exports.NavigationType = NavigationType;
49+
exports.WebViewDownloadEvent = WebViewDownloadEvent;
4550
exports.WebViewErrorEvent = WebViewErrorEvent;
4651
exports.WebViewHttpErrorEvent = WebViewHttpErrorEvent;
4752
exports.WebViewMessageEvent = WebViewMessageEvent;

src/ReactNativeWebView.re

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class type virtual webViewShouldStartLoadWithRequest = {
8787

8888
type webViewNavigationOrError;
8989

90+
module WebViewDownloadEvent = {
91+
type payload = {downloadUrl: string};
92+
93+
include Event.SyntheticEvent({
94+
type _payload = payload;
95+
});
96+
};
97+
9098
module WebViewErrorEvent = {
9199
type payload = Js.t(webViewError);
92100
include Event.SyntheticEvent({
@@ -192,6 +200,7 @@ external make:
192200
~mixedContentMode: [ | `never | `always | `compatibility]=?,
193201
~nativeConfig: nativeConfig=?,
194202
~onContentProcessDidTerminate: WebViewTerminatedEvent.t => unit=?,
203+
~onFileDownload: WebViewDownloadEvent.t => unit=?,
195204
~onError: WebViewErrorEvent.t => unit=?,
196205
~onHttpError: WebViewHttpErrorEvent.t => unit=?,
197206
~onLoad: WebViewNavigationEvent.t => unit=?,

0 commit comments

Comments
 (0)