built with coffee

JavaScript Generators

Nov 8, 2022

With Tim Tams, at Why Would Anyone Need JavaScript Generator Functions, an enjoyable write-up of a confusing part of JavaScript, although I’m not entirely sure I’d ever use them short of a library that hides all of the implementation details.

As noted in the Hacker News comments Redux-Saga uses generators, that’s where most of my knowledge of them comes from. After implementing it once (look at me, very smart!) I took over another project that used it and immediately ripped it out which, based on the replies, I’m not the only one:

I had to rescue a saga based project that went badly off the rails and it was some of the hardest code I’ve ever had to debug in any language. Code flow was very difficult to reason about and forget about trying to use stack traces. source

Posted: November 2022

Tagged: web dev