Skip to content

Conversation

@iwex
Copy link
Contributor

@iwex iwex commented Apr 27, 2017

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
Copy link
Contributor Author

iwex commented Apr 27, 2017

I'll add test if this changes is ok

@taylorotwell
Copy link
Member

I would call the method broadcastWhen

@iwex
Copy link
Contributor Author

iwex commented Apr 27, 2017

@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