https://github.com/cnkcq/globaltimer
A simple to use library that gets around a load of problems that arise when you start trying to do much inside 'loop'.
https://github.com/cnkcq/globaltimer
loop objective-c timer-clock
Last synced: 12 months ago
JSON representation
A simple to use library that gets around a load of problems that arise when you start trying to do much inside 'loop'.
- Host: GitHub
- URL: https://github.com/cnkcq/globaltimer
- Owner: CNKCQ
- License: mit
- Created: 2018-01-26T10:17:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T08:02:50.000Z (about 6 years ago)
- Last Synced: 2024-10-19T05:15:21.753Z (over 1 year ago)
- Topics: loop, objective-c, timer-clock
- Language: Objective-C
- Homepage:
- Size: 1.05 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GlobalTimer
[](https://travis-ci.org/wangchengqvan@gmail.com/GlobalTimer)
[](http://cocoapods.org/pods/GlobalTimer)
[](http://cocoapods.org/pods/GlobalTimer)
[](http://cocoapods.org/pods/GlobalTimer)

## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
* Xcode
* Objective-C
## Features
- [x] start a loop with an event.
- [x] pause a specific loop.
- [x] active a specific loop.
- [x] remove a specific loop.
- [x] update a loop with a new interval
## Installation
GlobalTimer is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'GlobalTimer'
```
## Api
```Objective-C
+ (instancetype _Nonnull )shared;
- (void)scheduledWith: (NSString * _Nonnull )identifirer timeInterval: (NSTimeInterval)interval repeat:(BOOL)repeat block:(GTBlock _Nonnull )block userinfo:(NSDictionary * _Nullable)userinfo;
- (void)updateEventWith: (NSString * _Nonnull )identifirer timeInterval: (NSTimeInterval)interval repeat:(BOOL)repeat block:(GTBlock _Nonnull )block userinfo:(NSDictionary * _Nullable)userinfo;
- (void)pauseEventWith: (NSString *_Nonnull)identifirer;
- (void)removeEventWith: (NSString *_Nonnull)identifirer;
- (void)activeEventWith:(NSString *_Nonnull)identifirer;
- (NSArray *_Nonnull)eventList;
```
## :book: Usage
```Objective-C
[[GTimer shared] scheduledWith:@"first" timeInterval:2 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"๐บ๐ธ%@", userinfo[@"test"]);
} userinfo:@{@"test": @"ok"}];
[[GTimer shared] scheduledWith:@"second" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"๐บ%@", userinfo[@"cnkcq"]);
} userinfo:@{@"cnkcq": @"king"}];
[[GTimer shared] scheduledWith:@"dog" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"๐ถ%@", userinfo[@"dog"]);
} userinfo:@{@"dog": @"ๆบ่ดข"}];
[[GTimer shared] scheduledWith:@"fourth" timeInterval:10 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"๐ฑ%@", userinfo[@"cat"]);
} userinfo:@{@"cat": @"ๅชๅช"}];
```
```Objective-C
[[GTimer shared] pauseEventWith:@"dog"];
NSLog(@"%@", [[GTimer shared] eventList]);
[[GTimer shared] activeEventWith:@"dog"];
[[GTimer shared] removeEventWith:@"fourth"];
```
## Reprensent

## Author
wangchengqvan@gmail.com, chengquan.wang@ele.me
## License
GlobalTimer is available under the MIT license. See the LICENSE file for more info.