Skip to content

[5.4] Conditional broadcasting - #18970

Merged
taylorotwell merged 4 commits into
laravel:5.4from
iwex:5.4
Apr 28, 2017
Merged

[5.4] Conditional broadcasting#18970
taylorotwell merged 4 commits into
laravel:5.4from
iwex:5.4

Conversation

@iwex

@iwex iwex commented Apr 27, 2017

Copy link
Copy Markdown
Contributor

Sometimes we should broadcast event only if some condition is true.

Example:

class Win implements ShouldBroadcast
{
    protected $score;
    protected $reportScore;
    
    public function __construct($score)
    {
        $this->score = $score;
    }
    
    public function broadcastCondition() {
        return $this->score > $this->reportScore;
    }

    public function broadcastOn()
    {
        return ['general-channel'];
    }
}

@iwex

iwex commented Apr 27, 2017

Copy link
Copy Markdown
Contributor Author

I'll add test if this changes is ok

@taylorotwell

Copy link
Copy Markdown
Member

I would call the method broadcastWhen

@iwex

iwex commented Apr 27, 2017

Copy link
Copy Markdown
Contributor Author

@taylorotwell done, please check

@tillkruss tillkruss changed the title Conditional broadcasting [5.4] Conditional broadcasting Apr 27, 2017
@taylorotwell
taylorotwell merged commit 013b475 into laravel:5.4 Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants