close
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update example code in README.md
  • Loading branch information
MaxDesiatov authored Oct 20, 2020
commit 3601a34156194cf95bea826317aac11f88852215
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ Can be written in Swift using JavaScriptKit
```swift
import JavaScriptKit

let alert = JSObject.global.alert.function!
let document = JSObject.global.document.object!
let document = JSObject.global.document

let divElement = document.createElement!("div").object!
let divElement = document.createElement("div")
divElement.innerText = "Hello, world"
let body = document.body.object!
_ = body.appendChild!(divElement)
_ = document.body.appendChild(divElement)

struct Owner: Codable {
let name: String
Expand All @@ -52,7 +50,7 @@ struct Pet: Codable {
let jsPet = JSObject.global.pet
let swiftPet: Pet = try JSValueDecoder().decode(from: jsPet)

alert("Swift is running on browser!")
JSObject.global.alert("Swift is running in the browser!")
```

### Usage in a browser application
Expand Down Expand Up @@ -130,4 +128,4 @@ $ ./scripts/install-toolchain.sh
$ swift --version
Swift version 5.3-dev (LLVM 09686f232a, Swift 5a196c7f13)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think vendor name can be updated 👍

@kateinoigakukun kateinoigakukun Oct 21, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that swiftwasm/swift#1921 is not included in 5.3 branch 😢 But now, it's ok without SwiftWasm vendor name...

Target: x86_64-apple-darwin19.6.0
```
```