File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
Swift framework to interact with JavaScript through WebAssembly.
6
6
7
+ ## Usage
8
+
9
+ This JavaScript code
10
+
11
+ ``` javascript
12
+ const alert = window .alert
13
+ const document = window .document
14
+
15
+ const divElement = document .createElement (" div" )
16
+ divElement .innerText = " Hello, world"
17
+ const body = document .body
18
+ body .appendChild (divElement)
19
+
20
+ alert (" JavaScript is running on browser!" )
21
+ ```
22
+
23
+ Can be written in Swift using JavaScriptKit
24
+
25
+ ``` swift
26
+ import JavaScriptKit
27
+
28
+ let alert = JSObjectRef.global .alert .function !
29
+ let document = JSObjectRef.global .document .object !
30
+
31
+ let divElement = document.createElement ! (" div" ).object !
32
+ divElement.innerText = " Hello, world"
33
+ let body = document.body .object !
34
+ _ = body.appendChild ! (divElement)
35
+
36
+ alert (" Swift is running on browser!" )
37
+ ```
38
+
39
+
40
+ Please see [ Example] ( https://github.com/kateinoigakukun/JavaScriptKit/tree/master/Example ) directory for more information
You can’t perform that action at this time.
0 commit comments