-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from l3aro/main
Key class customizable
- Loading branch information
Showing
6 changed files
with
107 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
use Livewire\Volt\Component; | ||
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; | ||
new class extends Component { | ||
use \DanHarrin\LivewireRateLimiting\WithRateLimiting; | ||
public $secondsUntilAvailable; | ||
public function clear() | ||
{ | ||
$this->clearRateLimiter('limit', component: 'VoltComponent'); | ||
} | ||
public function hit() | ||
{ | ||
$this->hitRateLimiter('limit', 1, component: 'VoltComponent'); | ||
} | ||
public function limit() | ||
{ | ||
try { | ||
$this->rateLimit(3, 1, component: 'VoltComponent'); | ||
} catch (TooManyRequestsException $exception) { | ||
return $this->secondsUntilAvailable = $exception->secondsUntilAvailable; | ||
} | ||
$this->secondsUntilAvailable = 0; | ||
} | ||
}; ?> | ||
|
||
<div> | ||
// | ||
</div> |