Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
theolampert authored Jan 20, 2024
1 parent c3b4488 commit e9a22c9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ let decoder = JSValueDecoder()
let runtime = Runtime()

// Example model, we'll decode from the Javascript runtime, after it's been fetched from the example API.
struct Product: Codable, Equatable {
let discountPercentage, rating: Double
struct Product {
let discountPercentage: Double
let rating: Double
let category: String
let id, price: Int
let id: Int
let price: Int
let title: String
let stock: Int
let thumbnail: String
let brand, description: String
let brand: String
let description: String
let images: [String]
}

// Conform it to Codable
extension Product: Codable {}

// Load the javascript source file defined above, alternatively JS can be written inline.
let javascriptSource = try! String(contentsOfFile: "./example.js")

Expand Down

0 comments on commit e9a22c9

Please sign in to comment.