Skip to content

Commit 4de646a

Browse files
Update README.md
1 parent baa697a commit 4de646a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ Quick port of the [Facebook's DataLoader](https://github.com/facebook/dataloader
1717
$userByIdLoader = new DataLoader(function ($ids) {
1818
$users = User::findMany($ids);
1919

20-
// Make sure that the users are on the same order as the given ids
20+
// Make sure that the users are on the same order as the given ids for the loader
2121
$orderedUsers = collect($ids)->map(function ($id) use ($users) {
22-
foreach ($users as $user) {
23-
if ($user->id === $id) {
24-
return $user;
25-
}
26-
});
22+
return $users->first(function ($user) use ($id) {
23+
return $user->id === $id;
24+
});
25+
});
2726

2827
return \React\Promise\resolve($orderedUsers);
2928
}, $eventLoopFromIoCContainer, $cacheMapFromIoCContainer);

0 commit comments

Comments
 (0)