@@ -57,18 +57,44 @@ To make this process even easier when using [Livewire](https://livewire.laravel.
57
57
listening to events. This is similar to
58
58
[ listening to Laravel Echo events using Livewire] ( https://livewire.laravel.com/docs/events#real-time-events-using-laravel-echo ) .
59
59
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
+
60
83
``` php
84
+ use Native\Laravel\Events\Windows\WindowBlurred;
85
+ use Native\Laravel\Events\Windows\WindowFocused;
86
+
61
87
class AppSettings extends Component
62
88
{
63
89
public $windowFocused = true;
64
90
65
- #[On('native:\Native\Laravel\Events\Windows\WindowFocused' )]
91
+ #[On('native:'.WindowFocused::class )]
66
92
public function windowFocused()
67
93
{
68
94
$this->windowFocused = true;
69
95
}
70
96
71
- #[On('native:\Native\Laravel\Events\Windows\WindowBlurred' )]
97
+ #[On('native:'.WindowBlurred::class )]
72
98
public function windowBlurred()
73
99
{
74
100
$this->windowFocused = false;
0 commit comments