Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Removing higher-order from collection-related tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed Mar 30, 2021
1 parent 3cf74c7 commit 1bb727f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ChannelManagers/LocalChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro
});

collect($channels)
->reject->hasConnections()
->reject(function ($channel) {
return $channel->hasConnections();
})
->each(function (Channel $channel, string $channelName) use ($connection) {
unset($this->channels[$connection->app->id][$channelName]);
});
Expand Down
4 changes: 3 additions & 1 deletion src/Channels/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ public function saveConnection(ConnectionInterface $connection)
public function broadcast($appId, stdClass $payload, bool $replicate = true): bool
{
collect($this->getConnections())
->each->send(json_encode($payload));
->each(function ($connection) use ($payload) {
$connection->send(json_encode($payload));
});

if ($replicate) {
$this->channelManager->broadcastAcrossServers($appId, null, $this->getName(), $payload);
Expand Down

0 comments on commit 1bb727f

Please sign in to comment.