This commit is contained in:
Alex Kim
2024-10-12 03:00:26 +11:00
parent 8be1e2df0c
commit 57354e6b06
6 changed files with 123 additions and 49 deletions

View File

@@ -9,36 +9,14 @@ public class VlcPlayerModule: Module {
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
// The module will be accessible from `requireNativeModule('VlcPlayer')` in JavaScript.
Name("VlcPlayer")
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
Constants([
"PI": Double.pi
])
// Defines event names that the module can send to JavaScript.
Events("onChange")
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
Function("hello") {
return "Hello world! 👋"
}
// Defines a JavaScript function that always returns a Promise and whose native code
// is by default dispatched on the different thread than the JavaScript runtime runs on.
AsyncFunction("setValueAsync") { (value: String) in
// Send an event to JavaScript.
self.sendEvent("onChange", [
"value": value
])
}
// Enables the module to be used as a native view. Definition components that are accepted as part of the
// view definition: Prop, Events.
View(VlcPlayerView.self) {
// Defines a setter for the `name` prop.
Prop("name") { (view: VlcPlayerView, prop: String) in
print(prop)
Prop("source") { (view: VlcPlayerView, source: String) in
view.setSource(source)
}
}
Function("hello") {
return "hello from native ios"
}
}
}