-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathows.ts
More file actions
28 lines (25 loc) · 718 Bytes
/
ows.ts
File metadata and controls
28 lines (25 loc) · 718 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
26
27
28
import * as ows from "npm:observables-with-streams";
export function main() {
Object.assign(window, { ows });
// const log = ows.tap(console.log)
ows
.merge(
ows.fromGenerator(function* () {
yield 100;
yield 200;
}),
ows
.fromEvent(document.querySelector("#dec")!, "click")
.pipeThrough(ows.map(() => -1)),
ows
.fromEvent(document.querySelector("#inc")!, "click")
.pipeThrough(ows.map(() => 1)),
)
.pipeThrough(ows.scan((v0, v1) => v0 + v1, 0))
.pipeThrough(new TransformStream<number, string>())
.pipeTo(
ows.subscribe((
v,
) => (document.querySelector("#counter")!.textContent = v)),
);
}