Slide 19
Slide 19 text
// async clusterfuck
fetchProfile($userName)->then(function ($profile) {
$fetch = function($userId, $cursor) use (&$fetch) {
return fetchFollowers($userId, $cursor)->then(function
($fs) use ($userId, $fetch) {
$cursor = $fs->next_cursor_str;
if ($cursor == "0")
return When::resolve($fs->ids);
else
return $fetch($userId,
$cursor)->then(function($ids) use($fs) { return
array_merge($fs->ids, ids); });
});
};
$fetch($profile->id, '-1')->then(function($ids) use($ids)
{ return [$profile, $ids]; })
});