What Tamagotchis Can Teach You About ES6 Generators
summary
A web Tamagotchi is implemented in canvas with sprite animations and the repo is linked; initial version uses promises for animations and hits two problems: promise chaining becomes callback-hell and promises can’t be cancelled so user events wait for long idle loops. The app is rewritten to rewrite animations as generators, to yield promises and let a co-routine resume them, and to cancel or pause idle animation to immediately handle feed events — the generator + co routine approach works in the demo.
AI-written summary · about
chapters (10)
- 0:00Start
- 5:52Creating the Main Game Loop
- 6:39Callback Health
- 11:09Pass Values into the Generators Next Function
- 12:26Create an Infinite Generator
- 16:51Co-Routines
- 18:50Co Routine To Handle Async Requests
- 21:37Draw Frame Generator
- 22:09Loop Generator
- 22:24While Loop
related talks
23mWhat Tamagotchis Can Teach You About ES6 Generators
26mWhat Tamagotchis can teach you about generators
36mThe Power of JS Generators
31mPromises and Generators: control flow utopia
15mI Yield for Generators
28mCreating generative art with Javascript
32mJavaScript 7: the Evolution of JavaScript
45mNext Generation Asynchronous Patterns in JavaScript
