-
Notifications
You must be signed in to change notification settings - Fork 0
/
NativeDataMarshallingExamples.js
64 lines (45 loc) · 2.19 KB
/
NativeDataMarshallingExamples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* This makes the JS forward looking, in that it supports the implementation of DataMarshallingExamples being a NativeModule or a TurboModule
* It also provides flow type information for the DataMarshallingExamples module, which in the future can be used to verify that the
* native implementation matches the JS definition.
*
* @flow
* @format
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export type Point = {|
X: number,
Y: number,
|};
export type Line = {|
Start: Point,
End: Point,
|};
export interface Spec extends TurboModule {
+ExplicitPrimtiveArgs(b: boolean, i: number, d: number, s: string) => void;
+ReturnExplicitBoolean(callback: (value: boolean) => void) => void;
+ReturnExplicitBooleanSync() => boolean;
+ReturnExplicitInteger(callback: (value: number) => void) => void;
+ReturnExplicitIntegerSync() => number;
+ReturnExplicitDouble(callback: (value: number) => void) => void;
+ReturnExplicitDoubleSync() => number;
+ReturnExplicitString(callback: (value: string) => void) => void;
+ReturnExplicitStringSync() => string;
+GetMidpoint(p1: Point, p2: Point, callback: (value: Point) => void) => void;
+GetMidpointSync(p1: Point, p2: Point) => Point;
+GetLength(line: Line, callback: (value: number) => void) => void;
+GetLengthSync(line: Line) => number;
+GetAverage(values: Array<number>, callback: (value: number) => void) => void;
+GetAverageSync(values: Array<number>) => number;
+Concatenate(values: Array<string>, callback: (value: string) => void) => void;
+ConcatenateSync(values: Array<string>) => string;
+Split(s: string, separators: string, callback: (value: Array<string>) => void) => void;
+SplitSync(s: string, separators: string) => Array<string>;
+JSValueArgs(b: boolean, i: number, d: number, s: string) => void;
+GetMidpointByJSValue(p1: Object, p2: Object, callback: (value: Object) => void) => void;
+GetMidpointByJSValueSync(p1: Object, p2: Object) => Object;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
'DataMarshallingExamples',
): Spec);