Raynos/main-loop — pull request #2 by neonstalwart (2014-05-12 22:22:20+00:00)
Title: remove unnecessary calls to schedule a redraw

when the loop is started, the initial state is rendered and so there is no need
to schedule a redraw for that state - a redraw only needs to happen when the
state changes.

when the state changes, `update` should be called and since initially,
`currentState` will be `null` and `redrawScheduled` will be `false`, a redraw
will be scheduled.

if another state change happens before the redraw then `redrawScheduled` will
prevent another redraw from being scheduled.

once `redraw` is called, a redraw is no longer scheduled and we just need to
determine how to update the previous rendering. if `currentState` is `null`
then there is no update (this logic was existing before this PR but i wonder
if even `null` should be rendered at least once after the transition from
something non-null)

at the end of `redraw` there is no need to schedule another redraw because that
should only be necessary if an update occurs and that shouldn't happen during a
redraw.