athaeryn/gitlife — pull request #1 by yihehe (2013-04-21 06:17:22+00:00)
Title: Speed control

Hey Mike, I implemented a speed control function for your gitlife simulation app. I hope it fits with what you had in mind. Temporarily, the user can change the speed (in ms) via a drop down list, but I think some sort of slider would be more suitable in the future.

The way I implemented was when the speed is changed, the js interval is cleared and restarted using the new speed.

I took the liberty of rearranging the GameOfLife class, placing the onStep and onComplete callbacks in the constructor. This way, we don't need to pass new functions into the class every time the user clicks on submit. This is also how I retrieved the onStep and onComplete functions when the interval is recreated following a speed change.

I would appreciate any feedback you may have, thanks for reading!