-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCounter.java
More file actions
25 lines (21 loc) · 785 Bytes
/
Counter.java
File metadata and controls
25 lines (21 loc) · 785 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
package rsp.app;
import rsp.component.ComponentView;
import rsp.component.definitions.InitialStateComponent;
import rsp.jetty.WebServer;
import static rsp.dsl.Html.*;
public final class Counter {
static void main(final String[] args) {
final ComponentView<Integer> view = newState -> state ->
html(
body(
h1("Current count: " + state),
button(on("click", _ -> newState.setState(state + 1)),
text("Increment"))
)
);
final var server = new WebServer(8080, _ -> new InitialStateComponent<>(0, view));
System.out.println("http://localhost:8080");
server.start();
server.join();
}
}