Slide 60
Slide 60 text
let appComponent = Component(initialState: 0, render: renderApp)
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(notification: NSNotification) {
appComponent.addToView(window.contentView)
}
}
func renderApp(component: Component, state: Int) -> Element {
return View(
backgroundColor: .orangeColor())
.justification(.Center)
.childAlignment(.Center)
.direction(.Column)
.children([
Label("You've clicked \(state) times!"),
Button(title: "Click me!", action: {
component.updateState { $0 + 1 }
})
.margin(Edges(uniform: 10))
.width(100),
])
}