Day 2. JS Generators
Continued with ES6 for Everyone – covered modules 16, 17 and 18 on Generators, Proxies and Sets. Generators used a rather advanced example which didn't make a lot of sense, so read through the first 3 of a series of blog posts from Kyle Simpson.
Async await can be achieved using generators, by ensuring that the last part of the method which completes the async functionality calls it.next(). However, there NEEDS to be some asynchronous part in here e.g. the fetch().then(). As soon as that async part gets hit, the yield returns undefined and that part of the calling function pauses. Then the Ajax call returns to the then(), which calls it.next(value) and the calling code resumes by sending out value (to e.g. an awaiting variable).
Also then started watching the latest hard parts course on Frontend Masters from Will Sentence. Completed the Introduction – recap on thread of execution / memory / call stack. Need to understand the event loop, plus generators and iterators in much more depth.