macOS ◆ xterm-256color ◆ fish 1572 views

This tutorial will guide you through installing Fly and running a simple task.

About Generators and Tasks

Every task inside your Flyfile is defined as a generator function, hence the function* syntax. Like other functions, a generator runs from top to bottom, but unlike other functions, they can be exited and reentered at any time.

This behavior is usually controlled using the yield keyword and an iterator object which the generator function returns the first time it is called.

You never use the iterator object in Fly, but you do use yield to hand over control to Fly and queue asynchronous operations. Using this syntax we escape callback hell.

You can yield any value from a generator function. If you yield a Promise, Fly is smart enough to unwrap it and reenter the generator after the promise is resolved. Fly is able to do this and more using pseudo-coroutines via co.

More by bucaran

untitled 00:23

by bucaran

untitled 03:00

by bucaran

untitled 02:06

by bucaran

untitled 00:08

by bucaran

See all