A simple to use library that gets around a load of problems that arise when you start trying to do
GlobalTimer
A simple to use library that gets around a load of problems that arise when you start trying to do much inside 'loop'.
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. To install
it, simply add the following line to your Podfile:
pod 'GlobalTimer'
Api
+ (instancetype _Nonnull )shard;
- (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<NSString *> *_Nonnull)eventList;
:book: Usage
[[GTimer shard] scheduledWith:@"first" timeInterval:2 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"??%@", userinfo[@"test"]);
} userinfo:@{@"test": @"ok"}];
[[GTimer shard] scheduledWith:@"second" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"?%@", userinfo[@"cnkcq"]);
} userinfo:@{@"cnkcq": @"king"}];
[[GTimer shard] scheduledWith:@"dog" timeInterval:5 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"?%@", userinfo[@"dog"]);
} userinfo:@{@"dog": @"旺财"}];
[[GTimer shard] scheduledWith:@"fourth" timeInterval:10 repeat:YES block:^(NSDictionary *userinfo) {
NSLog(@"?%@", userinfo[@"cat"]);
} userinfo:@{@"cat": @"咪咪"}];
[[GTimer shard] pauseEventWith:@"dog"];
NSLog(@"%@", [[GTimer shard] eventList]);
[[GTimer shard] activeEventWith:@"dog"];
[[GTimer shard] removeEventWith:@"fourth"];