File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Example/JavaScriptKitExample/Sources/JavaScriptKitExample Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import JavaScriptKit
2
2
3
3
let alert = JSObjectRef . global. alert. function!
4
4
let document = JSObjectRef . global. document. object!
5
+ let bluetooth = JSBluetooth . shared!
5
6
6
7
let divElement = document. createElement!( " div " ) . object!
7
8
divElement. innerText = " Hello, world "
@@ -11,7 +12,14 @@ _ = body.appendChild!(divElement)
11
12
let buttonElement = document. createElement!( " button " ) . object!
12
13
buttonElement. innerText = " Click me! "
13
14
buttonElement. onclick = . function { _ in
15
+ JSObjectRef . global. console. object? . log. function ? ( " \( #file) \( #function) \( #line) " )
14
16
alert ( " Swift is running on browser! " )
17
+ bluetooth. requestDevice ( ) . then {
18
+ JSObjectRef . global. console. object? . log. function ? ( " \( $0) " )
19
+ alert ( " Got device \( $0) " )
20
+ }
21
+ JSObjectRef . global. console. object? . log. function ? ( " \( #file) \( #function) \( #line) " )
22
+ return . undefined
15
23
}
16
24
17
25
_ = body. appendChild!( buttonElement)
You can’t perform that action at this time.
0 commit comments