@@ -57,18 +57,44 @@ To make this process even easier when using [Livewire](https://livewire.laravel.
5757listening to events. This is similar to
5858[ listening to Laravel Echo events using Livewire] ( https://livewire.laravel.com/docs/events#real-time-events-using-laravel-echo ) .
5959
60+ You may use a string name:
61+
62+ ``` php
63+ class AppSettings extends Component
64+ {
65+ public $windowFocused = true;
66+
67+ #[On('native:\\Native\\Laravel\\Events\\Windows\\WindowFocused')]
68+ public function windowFocused()
69+ {
70+ $this->windowFocused = true;
71+ }
72+
73+ #[On('native:\\Native\\Laravel\\Events\\Windows\\WindowBlurred')]
74+ public function windowBlurred()
75+ {
76+ $this->windowFocused = false;
77+ }
78+ }
79+ ```
80+
81+ You may find it more convenient to use PHP's class name resolution keyword, ` ::class ` :
82+
6083``` php
84+ use Native\Laravel\Events\Windows\WindowBlurred;
85+ use Native\Laravel\Events\Windows\WindowFocused;
86+
6187class AppSettings extends Component
6288{
6389 public $windowFocused = true;
6490
65- #[On('native:\Native\Laravel\Events\Windows\WindowFocused' )]
91+ #[On('native:'.WindowFocused::class )]
6692 public function windowFocused()
6793 {
6894 $this->windowFocused = true;
6995 }
7096
71- #[On('native:\Native\Laravel\Events\Windows\WindowBlurred' )]
97+ #[On('native:'.WindowBlurred::class )]
7298 public function windowBlurred()
7399 {
74100 $this->windowFocused = false;
0 commit comments