observer example from Programming Scala