-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[11.x] Adds anonymous broadcasting #51082
Conversation
Would it be worth having a Broadcast::private('my-channel')
->as('my-event-name')
->with(['some' => 'array', 'of' => 'data'])
->via('reverb')
->toOthers()
->send(); |
74d7b54
to
5264f43
Compare
Consider it done 🚀 |
Awesome! Will be a very good addition. I'd like to suggest an interesting addition in my opinion. As we know Broadcast has two ways of being dispatched, From what I can understand, this will always be dispatched using So, it might be interesting to think about something like: Broadcast::on('my-channel')->send(); Broadcast::on('my-channel')->sendNow(); Or simply: Broadcast::on('my-channel')->send(queueable: false); An easy way to achieve this result would be to change the implementation of |
@devajmeireles implemented. |
@joedixon Cool feature. But is there is a way to broadcast after db commit as we can do with events by implementing interface |
Sometimes you may wish to broadcast an ad-hoc event.
An ad-hoc event is one where you don't need to hook into it anywhere else in your application. You just want to notify the frontend of something.
For this, you don't want to go to the trouble of creating a brand new event, you just want to fire off a message.
For this, we can use an anonymous broadcast using the
Broadcast
facade, which can be as simple as:Results in...
You may dispatch to multiple channels at the same time:
You may also configure the name, payload, broadcasting connections and whether or not it should only be dispatched to others:
Results in...
Edit:
After feedback from @lukeraymonddowning, the following conveniences were added: