Easily implement broadcasting in a React/Vue Typescript app (Starter Kits) #55170
+509
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is going to make the process of implementing broadcasting in the React/Vue starter kits super simple.
This PR will detect if a users application utilizes
react
orvue
. It will also check for the existense of thetypescript
dependency. Then, when the developer runs thephp artisan install:broadcasting
command it will install the necessary Echo hook or composable.React
Running
php artisan install:broadcasting
, theuse-echo-ts.stub
will be installed in theresources/js/hooks
folder. It can then be leveraged inside of any component, like so:This will subscribe to
test-channel
and log the payload whentest.event
is fired.Vue
Running
php artisan install:broadcasting
, theuseEcho-ts.stub
will be installed in theresources/js/composables
folder. It can then be leveraged inside of any component, like so:This is the exact same as React except the
useEcho
is stored in thecomposables
folder as opposed to thehooks
folder.Configuration
Before using this hook/composable, echo needs to be configured, like so:
app.tsx
This will allow developers to modify echo to use
reverb
,pusher
,ably
or any other websocket service. This is going to be added by default (Still adding this functionality to theinstall:broadcasting
command. After I finish implementing the publishing of the configure, this update will be good to go!