Skip to content

Commit b79a073

Browse files
committed
Remove some unnecessary methods in the Brodcasts trait
These methods are duplicate since we do check for them in the \Tonysm\TurboLaravel\TurboStreamModelRenderer class.
1 parent e401685 commit b79a073

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

src/LaravelBroadcaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function exceptForSocket(string $socket = null): self
1818
return $this;
1919
}
2020

21-
public function create($model): void
21+
public function create(Model $model): void
2222
{
2323
$action = property_exists($model, 'turboStreamCreatedAction')
2424
? $model->turboStreamCreatedAction
@@ -30,7 +30,7 @@ public function create($model): void
3030
));
3131
}
3232

33-
public function update($model): void
33+
public function update(Model $model): void
3434
{
3535
$action = property_exists($model, 'turboStreamUpdatedAction')
3636
? $model->turboStreamUpdatedAction

src/Models/Broadcasts.php

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ public function queueBroadcastUpdatedToHotwire()
6060

6161
public function queueBroadcastRemovalToHotwire()
6262
{
63-
// Removals cannot be cached because we need to gather the broadcasting targets
64-
// using the model instance's relationships before the entity is "gone".
63+
// We cannot queue removal broadcasts because the model will be gone once the worker
64+
// picks up the job to process the broadcasting. So we are broadcasting after the
65+
// response is sent to back to the user, before the PHP process is terminated.
6566

6667
app()->terminating(function () {
6768
$this->hotwireBroadcastUsing()
@@ -74,31 +75,4 @@ public function hotwireBroadcastUsing()
7475
{
7576
return resolve(LaravelBroadcaster::class);
7677
}
77-
78-
public function hotwireTargetDomId()
79-
{
80-
return $this->hotwireResolveNamesUsing()->domIdFor($this);
81-
}
82-
83-
public function hotwireTargetResourcesName()
84-
{
85-
return $this->hotwireResolveNamesUsing()->resourceName($this);
86-
}
87-
88-
public function hotwireResolveNamesUsing(): NamesResolver
89-
{
90-
return resolve(NamesResolver::class);
91-
}
92-
93-
public function hotwirePartialName()
94-
{
95-
return $this->hotwireResolveNamesUsing()->partialNameFor($this);
96-
}
97-
98-
public function hotwirePartialData()
99-
{
100-
return [
101-
$this->hotwireResolveNamesUsing()->resourceVariableName($this) => $this,
102-
];
103-
}
10478
}

0 commit comments

Comments
 (0)