function fetchProduct()
{
$cursor = r\table("tableOne")->changes()->run($conn);
foreach ($cursor as $product) {
yield $product;
}
}
$product = fetchProduct();
var_dump($product);
echo "i"; //when the function use yield, this line executed. But when return used, it doesn't come to this line.
I understand rethinkdb's changes()
will keep listening to the changes so i found that its better to use yield over the $cursor
. But the yield
doesn't return value to the calling party. But when return is used value returned.
How to make the yield to return any value when changes occur?
References:
https://rethinkdb.com/docs/async-connections/
What does yield mean in PHP?
No comments:
Post a Comment