unread
Hi!
Is it possible to somehow detect if a generator can accept any send()
command? That is, if it has any line like this:
$gen = yield;
Use-case is when generators are used to factor out side-effects (as in
redux-saga). If no expression depends on the result of any
side-effect, all side-effects can be run concurrently (non-blocking
IO). Otherwise, the code should wait.
Example:
yield $io->db->query('UPDATE table ...'); // Don't wait, run as async
$result = yield $io->db->query('SELECT id FROM ...'); // Wait for result
I've looked into Amphp but didn't find any way to do this yet. Maybe
async()/await() functions (not language constructs) would work?
Thank you for any feedback.
Olle