You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As in JavaScript i get result after 5 sec > "onetwothree"
but here it behave as normal php, get result after 15sec. so what i the benefit of this react.
///////////////////////////
Let Suppose i have three query to mysql;
Q1, Q2, Q3
can in React these run in parallel ?
if these run like Q1 then Q2 and then Q3, so why we use React.
The text was updated successfully, but these errors were encountered:
Promises don't make synchronous code magically asynchronous (#120 and others). In fact, your code snippet does not even use promises.
It looks like you may not want to "sleep" (i.e. "pause" the execution of the program) but rather "await" a timer to fire. In this case, you can directly use the loop and adjust your timer numbers accordingly in your previous example or use the React\Promise\Timer\resolve() function like this:
`$one = function() {
sleep(5);
echo "one";
};
$two = function() {
sleep(5);
echo "two";
};
$three = function() {
sleep(5);
echo "three";
};
$loop = \React\EventLoop\Factory::create();
$loop->addTimer(1,function() use($one) {
$one();
});
$loop->addTimer(1,function() use($two) {
$two();
});
$loop->addTimer(1,function() use($three) {
$three();
});
$loop->run();`
As in JavaScript i get result after 5 sec > "onetwothree"
but here it behave as normal php, get result after 15sec. so what i the benefit of this react.
///////////////////////////
Let Suppose i have three query to mysql;
Q1, Q2, Q3
can in React these run in parallel ?
if these run like Q1 then Q2 and then Q3, so why we use React.
The text was updated successfully, but these errors were encountered: