Javascript Generators are AWESOME. At first glance, they seem overly simple and not very useful, but with a little bit of library love, they turn your async javascript from awful to joyful.
View the code here: https://gist.github.com/learncodeacademy/bf04432597334190bef4
If you don’t know promises, watch this video: http://www.youtube.com/watch?v=obaSQBBWZLk&list=UUVTlvUkGslCV_h-nSAId8Sw
Basically, ES6 generators give you the ability to write async code as if it were synchronous code. It literally looks like you’re not even writing async code! Harmony generators are definitely, without a doubt, the most powerful upgrade that javascript is receiving with ES6 harmony.
Original source
40 responses to “Javascript Generators – THEY CHANGE EVERYTHING – ES6 Generators Harmony Generators”
The video was good until you started using Jquery.
I was following until 2:50. I don't understand why do you have to pass data into the next function? I love your channel! Liked, subscribed.
Awesome video, I wish I had seen this before reading material online!
Great vids! Have you purchased a Sublime Text license since this video? 🙂
lol 2014 was a different world…
Awesome
That's the first video about generators that actually made some sense to me. Thanks!
this is so awesome. no more Promise.then(function(somecrap){ $scope.crap = somecrap; }); in Angular
Awesome videos! The web needs more of this.
Nice tutorial!
Your voice reminds me of Donald Trump's one…
If you tweak it a bit you can end up with a nice voice impression!
I might have given a little applause at 5:50
#mindblown
Can you guys clarify something for me? This example tells us that we can not call next() on a closed generator. I tried this in both Node and the browser and if I call next() a bunch of more times it just returns "value: undefined, done: true" over and over again. Has this changed since august 2014 when this video was made or am I overlooking something silly?
Thank you! ?
Enjoy the rest of my JavaScript life?! Who does that?
Promise.coroutine works great but this line in your myGen – it doesn't work for me: one = yield $.get('/api/friends') stays undefined
You can use most of ES6 features with out babel or Tracuer 🙂
wait what? yield only shots promise object when gen.next() is called, it doesn't wait for promise to resolve, that's single responsibility principle violation, or does it? I'm confused. Also isn't it just replica of Promise.all(), Promise.any() functionality? Video is delivered like it is completely new thing, but it's just a standardizing process of old stuff. Could someone explain?
Hey! Where can I get the same syntax/color scheme theme?
Nice cool stuff!!! thanks!
Man! Im cheering for you at this moment tapping my table! Thanks for explaining!
Can you tell about using Monads in JS?
That's cool.
very nice tutorial. Thanks a lot man 🙂 🙂 🙂
how I enjoy the rest of my ES6 life…
q? bluebird? what? traceur?
thanks for the video.
man, I like the last statement you made! and love seeing how I enjoy the rest of my JS life. In the past year, I have hands-on exp on JS and really like the idea of being a JS ninja, JS junkie. I see programming and coding in JS is not only fun but sharp, concise, efficient, way better syntactic (syntax + tactics) than tight-types. rigirous syntaxes of C# and Java.
Because JS is loose-type, there comes easy ways to define objects, object classes and wire up things. There comes Prototypical programming patterns.
The only downside of JS (weakness too as compared to years of C++,C#, Java drive them into standardized languages) is that JS from ECMA Script wasn't much developed in the past and the language undergoes exploration and development. Adjustment and changes come and create inconsistency, unconventional and unstandardized ecosystem for JS generations of developers. ECMA and Browser ( the compiler. IIRC: big name is Chrome) are still hesitant to have full exchange, collaboration and agreement on how things go for future web. I hope Google pushes it to have strong tie to future with ES forks.
Wow this is sick. Awesome content delivery.
COOL!!!!!!!!!!!!!!
Great tutorial, but I'm a bit confused — how is promisfying it making it asycnrhonous? Doesn't it wait for each promise to finish before doing the next one?
ES6 native promise have coroutine ?
So is the generator mainly made for resolve ajax asynchronous problems?
"Traceur" would be pronounced "Trah-sir" in French
Great video! I was going through generator/promises tutorials and had no idea why the hell I was learning it for but it all clicked after watching this and the last video on promises. Thanks!
Hey , What screen recorder did you use?
I read some posts and I don't got it, until i saw your video. Thanks men keep doing this.
holy shit! the possibilities of this functionality! i watched this a couple of months ago and it didnt make any sense but now that i know a little bit about functions i think this like what you said, "a game changer!"
Dude, I am super new to JS and more so to ECMA6 and your enthusiasm has me UBER excited to really get this stuff.
Js took many years to have a simple way of writing synchronous code in it's universal implementation, yet no thaaat simple…
Still, I can't hide my enthusiasm with these new features that long existed everywhere
Seem pointless?
It's not! (And here is my life for a moment)
SUBSCRIBED
Good one!!! You rock
Silly question, but why are you declaring your functions with an asterisk? (function* (){})