https://github.com/alexito4/sometimes
Small Swift library that makes it easy to run code... sometimes. Well, actually, just once.
https://github.com/alexito4/sometimes
Last synced: 5 months ago
JSON representation
Small Swift library that makes it easy to run code... sometimes. Well, actually, just once.
- Host: GitHub
- URL: https://github.com/alexito4/sometimes
- Owner: alexito4
- License: mit
- Created: 2015-11-24T21:08:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-19T10:44:02.000Z (over 9 years ago)
- Last Synced: 2025-01-02T04:12:50.128Z (7 months ago)
- Language: Swift
- Homepage:
- Size: 8.02 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sometimes
[](https://raw.githubusercontent.com/alexito4/Sometimes/master/LICENSE.md)
[](https://github.com/alexito4/Sometimes/releases)
[](https://travis-ci.org/alexito4/Sometimes)
[](https://github.com/Carthage/Carthage)This is a small Swift library that makes it easy to run code... sometimes. Well, actually, just once.
Sometimes.execute(key) {
// This will run just once
}
Inspired by [RateLimit](https://github.com/soffes/RateLimit) and [SwiftyUserDefaults](https://github.com/radex/SwiftyUserDefaults).
## Usage
Each block of code is associated to a `SometimesKey`. No stringly typed API here.let key = SometimesKey("test_key")
Then just execute it using the key.Sometimes.execute(key) {
// This will run just once
}Keys are persisted by default in the `NSUserDefaults.standardUserDefaults()`.
A function to remove all keys is also provided.
Sometimes.reset()
## Integration
If you are using [Carthage](https://github.com/Carthage/Carthage) just add `github "alexito4/Sometimes”` to your `Cartfile`.Then, just import it:
import Sometimes
## Author
Alejandro Martinez, [email protected]
## License
Available under the MIT license. See the LICENSE file for more info.