1

I am searching for an equivalent to Laravel's broadcastWhen() function to use it for my events.

Goal is to reduce events placed on the queue by certain conditions.

I tried using a Event which implements the ShouldBroadcast Interface, but surely the event got still fired and received by the listener.

So the idea should kind of look like:

class TestEvent extends Event
{
    use SerializesModels;

    public $message;

    public function __construct(int $message)
    {
        $this->message = $message;
    }

    /**
     * Determine if this event should placed on the queue.
     *
     * @return bool
     */
    public function addToQueueWhen()
    {
        return $message < 0
    }
}

Thanks for your help

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.