-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run dataloader for simple example #29
Comments
Can you give this a try please: use GuzzleHttp\Promise\Promise;
use Overblog\DataLoader\DataLoader;
use Overblog\PromiseAdapter\Adapter\GuzzleHttpPromiseAdapter;
class Sandbox
{
public function handle()
{
$promiseAdapter = new GuzzleHttpPromiseAdapter();
$myBatchGetUsers = function ($keys) use ($promiseAdapter) {
echo "Running myBatchGetUsers()...\n";
return $promiseAdapter->createAll([
['name' => 'John'],
['name' => 'Sara'],
]);
};
$userLoader = new DataLoader($myBatchGetUsers, $promiseAdapter);
$userLoader->load(4)
->then(function ($user) use ($userLoader) {
echo "{$user['name']}\n"; // never runs
});
$userLoader->load(5)
->then(function ($user) use ($userLoader) {
echo "{$user['name']}\n"; // never runs
});
$userLoader->await();
}
} |
That worked. Thank you! Can you perhaps update the docs (or perhaps point me to the right direction) so that I can understand how |
Thanks for feedback we'll update the documentation to make this part a little clearer. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am really struggling to create even a simple version of this using the documentation.
Here is my code:
The expected output is:
However the actual output is:
As you can see it is a very simple example, yet it does not work.
What am I doing wrong?
Many Thanks :-)
The text was updated successfully, but these errors were encountered: