Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Conditional broadcasting #18970

Merged
merged 4 commits into from
Apr 28, 2017
Merged

[5.4] Conditional broadcasting #18970

merged 4 commits into from
Apr 28, 2017

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