Skip to content

Commit f8273d6

Browse files
committed
bugfix: enable onlive diagram update
1 parent 138f079 commit f8273d6

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Chrome System Monitor
2+
=========
3+
Simple example of chrome application.
4+
5+
## For developers
6+
To create unpacked application:
7+
8+
```
9+
sbt
10+
chromeUnpackedFast
11+
````
12+
You can find result in `./target/chrome/unpacked-fast` folder.

src/main/scala/monitor/Timeline.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ class Timeline[T](val sampleCount: Int, val sampleInterval: FiniteDuration)(fun:
5454
listeners -= listener
5555
}
5656

57-
private def tick(): Unit =
58-
fun.foreach(addSample)
57+
private def tick(): Future[Unit] = for {
58+
sample <- fun
59+
_ <- Future.traverse(addSample(sample))(_.toFuture)
60+
} yield ()
5961

6062

6163
def start() = {
6264
if (intervalHandler.isEmpty)
6365
intervalHandler = Some(js.timers.setInterval(sampleInterval)(tick()))
66+
67+
this
6468
}
6569

6670
def stop() = intervalHandler foreach js.timers.clearInterval

src/main/scala/monitor/modules/Memory.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ object Memory extends Module {
2525

2626
class Backend[T](scope: BackendScope[Timeline[T], _]) extends Listener[Timeline[T]] {
2727

28-
def update(timeline: Timeline[T]): CallbackTo[Unit] =
29-
scope.forceUpdate
28+
def update(timeline: Timeline[T]): CallbackTo[Unit] = {
29+
println("Memory update")
3030

31+
scope.forceUpdate
32+
}
3133
}
3234

3335
val memoryTimeline = {
3436
val timeline = new Timeline[MemoryInfo](60, 1.second)(
3537
chrome.system.memory.Memory.getInfo
3638
)
3739
timeline.start()
38-
timeline
3940
}
4041

4142
val comp = ScalaComponent.builder[Timeline[MemoryInfo]]("Memory")

0 commit comments

Comments
 (0)