Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keisukeyamagishi/throttle
https://github.com/keisukeyamagishi/throttle
apple ios swift throttle
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/keisukeyamagishi/throttle
- Owner: keisukeYamagishi
- License: mit
- Created: 2023-04-09T12:57:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T11:11:25.000Z (11 months ago)
- Last Synced: 2024-12-11T22:35:57.612Z (about 2 months ago)
- Topics: apple, ios, swift, throttle
- Language: Swift
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Throttle
ThrottleThis is my implementation of a throttle in Swift, inspired by Krunoslav Zaher's code. If you're looking to use a throttle that doesn't rely on Combine or RxSwift, I hope you'll find this code useful as a reference.
## Use it
***Via SSH***: For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub):
```
$ git clone [email protected]:keisukeYamagishi/Throttle.git
```
***Via https***: For those checking out sources as read-only, HTTPS works best:```
$ git clone https://github.com/keisukeYamagishi/Throttle.git
```## Installation
### Swift Package Manager
`File` > `Swift Packages` > `Add Package Dependency`
Add `https://github.com/keisukeYamagishi/Throttle.git`
Select "Up to Next Major" or "1.0.0"
### Cocoapods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```Write the following into the `Podfile`
```Swift
pod 'Throtlle'
```
Then, run the following command:```bash
$ pod setup
$ pod install
```## Usage
```Swift
import Throttle
import UIKitfinal class ViewController: UIViewController {
let throttle = Throttle()@IBAction func pushInButton(_: Any) {
throttle
.execute(interval: .seconds(3)) {
print("Time passed")
}
}
}
```