es2015 generator concepts - nyc node.js meetup 20150316

Post on 10-Apr-2017

356 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

ES2015 Generator Concepts

Valeri KarpovPlatform Tech Lead, Booster Fuels

thecodebarbarian.comgithub.com/vkarpov15

@code_barbarian

What This Talk is About● What is a generator?● What can you do with it?● How does co work?

Terminology● Generator function

● Generator object (or just generator)

The Yield Keyword● yield allows re-entry

The Key Idea of Generators● Yield pauses generator function execution● Calling next() resumes execution● Can call next() asynchronously

Why Is This Useful?

Separate Logic From Scheduling

Yielding a Promise

What’s Next?● Check out The 80/20 Guide to ES2015

Generators● Rigorous guide to generators as spec-ed

with minimal outside dependencies○ No babel, webpack, angular, react, gulp, etc. etc.

● More detail on how co works● Plus koa, the web framework based on co● Plus regenerator, Facebook’s transpiler

Thanks for Listening!Comments, questions, haikus?

Read more at:thecodebarbarian.comgithub.com/vkarpov15

@code_barbarian

top related