Removing higher-order from collection-related tasks

This commit is contained in:
Alex Renoki 2021-03-30 18:11:58 +03:00
parent 3cf74c7a50
commit 1bb727f322
2 changed files with 6 additions and 2 deletions

View File

@ -179,7 +179,9 @@ class LocalChannelManager implements ChannelManager
});
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]);
});

View File

@ -156,7 +156,9 @@ class Channel
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);