Simplify example code even more in README.md

This commit is contained in:
Max Desiatov 2020-06-18 18:45:15 +01:00 committed by GitHub
parent 6349f5388a
commit 27156a56a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 7 deletions

View File

@ -29,14 +29,8 @@ import TokamakDOM
public struct Counter: View {
@State public var count: Int
let limit: Int
public init(_ count: Int, limit: Int = Int.max) {
_count = .init(wrappedValue: count)
self.limit = limit
}
public var body: some View {
count < limit ?
AnyView(
@ -62,7 +56,7 @@ import TokamakDOM
let document = JSObjectRef.global.document.object!
let divElement = document.createElement!("div").object!
let renderer = DOMRenderer(Counter(5), divElement)
let renderer = DOMRenderer(Counter(count: 5, limit: 15), divElement)
let body = document.body.object!
_ = body.appendChild!(divElement)