-
Couldn't load subscription status.
- Fork 11.6k
Easily implement broadcasting in a React/Vue Typescript app (Starter Kits) #55170
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
Conversation
|
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
Drafting this while I review. |
|
I've updated this PR to only include the configureEcho functionality when installing in a React/Vue(typescript) app. The actual javascript functionality and hooks have been moved over to this PR. The updated version of Echo should be published before merging this. |
…ework into pr/tnylea/55170
| /** | ||
| * Write an array of key-value pairs to the environment file. | ||
| * | ||
| * @param array $variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param array $variables | |
| * @param array<string, mixed> $variables |
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
reactorvue. It will also check for the existense of thetypescriptdependency. Then, when the developer runs thephp artisan install:broadcastingcommand it will install the necessary Echo hook or composable.React
Running
php artisan install:broadcasting, theuse-echo-ts.stubwill be installed in theresources/js/hooksfolder. It can then be leveraged inside of any component, like so:This will subscribe to
test-channeland log the payload whentest.eventis fired.Vue
Running
php artisan install:broadcasting, theuseEcho-ts.stubwill be installed in theresources/js/composablesfolder. It can then be leveraged inside of any component, like so:This is the exact same as React except the
useEchois stored in thecomposablesfolder as opposed to thehooksfolder.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,ablyor any other websocket service. This is going to be added by default (Still adding this functionality to theinstall:broadcastingcommand. After I finish implementing the publishing of the configure, this update will be good to go!