Promises and Generators

evertpot

Many of you have heard of the concept 'Promise'. Some of you may even have used
it. The 'Promise' is a useful design pattern when developing applications that
have a strong asynchronous aspect and avoids what's called 'callback hell' or
'callback christmas trees'.

The promise is a bit hard to wrap your head around though. This talk will
explain exactly how a promise works and behaves and how you should interact
with it.

Next, we'll dig into generators. Generators have been added to PHP 5.5 and
Ecmascript 6 and makes creating and consuming iterators a lot easier.

Generators have a unique language property though. They allow us to jump in
the middle of any method outside that method. In the third part of the talk
we'll show how we can use iterators to improve promise-heavy code and make
asynchronous code look and behave as normal code.

 

Session Track

PHP

Experience Level

Advanced

Drupal Version