Something like that?:
act =
loop {
react {
case Repaint(a, b) => if (lastRepaint + minInterval < System.currentTimeMillis) {
lastRepaint = System.currentTimeMillis
repaint(a, b)
}
}
If you want to redraw when the actor’s stream gets a chance, but no more, then: (UPDATE: redrawing using the last message arguments)
act =
loop {
react {
case r@Repaint(_, _) =>
var lastMsg = r
def findLast: Unit = {
reactWithin(0) {
case r@Repaint(_, _) =>
lastMsg = r
case TIMEOUT => repaint(lastMsg.a, lastMsg.b)
}
}
findLast
}
}
source
share