forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSNameAPIs.swift
More file actions
34 lines (26 loc) · 740 Bytes
/
Copy pathJSNameAPIs.swift
File metadata and controls
34 lines (26 loc) · 740 Bytes
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
import JavaScriptKit
@JS("renamedEcho") func jsNameEcho(_ value: String) -> String {
return "echo: \(value)"
}
@JS("greetName") func greet(_ name: String) -> String {
return "Hello, \(name)!"
}
@JS("greetCount") func greet(_ count: Int) -> String {
return "Hello, \(count) people!"
}
@JS class JSNameRenamedClass {
private var storage: Int
@JS init(value: Int) {
self.storage = value
}
@JS("current") var value: Int {
get { storage }
set { storage = newValue }
}
@JS("doubled") func timesTwo() -> Int {
return storage * 2
}
@JS("makeWithValue") static func create(value: Int) -> JSNameRenamedClass {
return JSNameRenamedClass(value: value)
}
}