I just ran into an interesting situation where I knew I wanted to use Livewire because it was so darn simple, but what I was doing actually had no relation to any component.
I’m building a platform for a video course I’m launching and I wanted to detect when the user updates the playback speed on a video and save that value to the db, so for future videos the saved playback speed is used. I already had a different component on the page, so I just added the following in the blade template:
@push('scripts')
<script>
function onPlayerPlaybackRateChange(event) {
@this.call('setPlaybackRate', event.data);
}
</script>
@endpush
And the following in the component:
public function setPlaybackRate($value)
{
$user = request()->user();
$user->update([
'playback_rate' => $value,
]);
}
You’ll notice this has nothing at all to do with the component. I’m wondering if other people have run into this type of implementation. It works great, but if I didn’t have another component on this page, I would have had to create a new Livewire component that just did nothing to enable this API request.
I’m wondering if other people are using Livewire in the same way, and if so, if there should be some kind of stripped down version of a Livewire component where you don’t even have a render function.