Skip to content

Commit 12aa9dd

Browse files
sgnycknitt
authored andcommitted
Define syntheticEvent for Image onLoad callback (#461)
1 parent 94cf71a commit 12aa9dd

4 files changed

Lines changed: 42 additions & 16 deletions

File tree

‎reason-react-native/src/components/Image.md‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,26 @@ module DefaultSource = {
5252
external fromRequired: Packager.required => t = "%identity";
5353
};
5454
55+
type imageLoadEvent =
56+
Event.syntheticEvent({
57+
.
58+
"source": {
59+
.
60+
"width": float,
61+
"height": float,
62+
"url": string,
63+
},
64+
"uri": Js.Nullable.t(string),
65+
});
66+
5567
type errorEvent = Event.syntheticEvent({. "error": string});
5668
57-
type progress = {
58-
.
59-
"loaded": float,
60-
"total": float,
61-
};
69+
type progressEvent =
70+
Event.syntheticEvent({
71+
.
72+
"loaded": float,
73+
"total": float,
74+
});
6275
6376
[@react.component] [@bs.module "react-native"]
6477
external make:
@@ -74,11 +87,11 @@ external make:
7487
~loadingIndicatorSource: array(Source.t)=?,
7588
~onError: errorEvent => unit=?,
7689
~onLayout: Event.layoutEvent => unit=?,
77-
~onLoad: unit => unit=?,
90+
~onLoad: imageLoadEvent => unit=?,
7891
~onLoadEnd: unit => unit=?,
7992
~onLoadStart: unit => unit=?,
8093
~onPartialLoad: unit => unit=?,
81-
~onProgress: progress => unit=?,
94+
~onProgress: progressEvent => unit=?,
8295
~progressiveRenderingEnabled: bool=?,
8396
~resizeMethod: [@bs.string] [ | `auto | `resize | `scale]=?,
8497
~resizeMode: [@bs.string] [

‎reason-react-native/src/components/Image.re‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,26 @@ module DefaultSource = {
4545
external fromRequired: Packager.required => t = "%identity";
4646
};
4747

48+
type imageLoadEvent =
49+
Event.syntheticEvent({
50+
.
51+
"source": {
52+
.
53+
"width": float,
54+
"height": float,
55+
"url": string,
56+
},
57+
"uri": Js.Nullable.t(string),
58+
});
59+
4860
type errorEvent = Event.syntheticEvent({. "error": string});
4961

50-
type progress = {
51-
.
52-
"loaded": float,
53-
"total": float,
54-
};
62+
type progressEvent =
63+
Event.syntheticEvent({
64+
.
65+
"loaded": float,
66+
"total": float,
67+
});
5568

5669
[@react.component] [@bs.module "react-native"]
5770
external make:
@@ -67,11 +80,11 @@ external make:
6780
~loadingIndicatorSource: array(Source.t)=?,
6881
~onError: errorEvent => unit=?,
6982
~onLayout: Event.layoutEvent => unit=?,
70-
~onLoad: unit => unit=?,
83+
~onLoad: imageLoadEvent => unit=?,
7184
~onLoadEnd: unit => unit=?,
7285
~onLoadStart: unit => unit=?,
7386
~onPartialLoad: unit => unit=?,
74-
~onProgress: progress => unit=?,
87+
~onProgress: progressEvent => unit=?,
7588
~progressiveRenderingEnabled: bool=?,
7689
~resizeMethod: [@bs.string] [ | `auto | `resize | `scale]=?,
7790
~resizeMode: [@bs.string] [

‎reason-react-native/src/components/ImageBackground.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ external make:
5959
~onLoadEnd: unit => unit=?,
6060
~onLoadStart: unit => unit=?,
6161
~onPartialLoad: unit => unit=?,
62-
~onProgress: Image.progress => unit=?,
62+
~onProgress: Image.progressEvent => unit=?,
6363
~progressiveRenderingEnabled: bool=?,
6464
~resizeMethod: [@bs.string] [ | `auto | `resize | `scale]=?,
6565
~resizeMode: [@bs.string] [

‎reason-react-native/src/components/ImageBackground.re‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ external make:
5252
~onLoadEnd: unit => unit=?,
5353
~onLoadStart: unit => unit=?,
5454
~onPartialLoad: unit => unit=?,
55-
~onProgress: Image.progress => unit=?,
55+
~onProgress: Image.progressEvent => unit=?,
5656
~progressiveRenderingEnabled: bool=?,
5757
~resizeMethod: [@bs.string] [ | `auto | `resize | `scale]=?,
5858
~resizeMode: [@bs.string] [

0 commit comments

Comments
 (0)