mirror of
https://github.com/easychen/pushdeer.git
synced 2024-09-09 22:38:16 +08:00
15 lines
506 B
Objective-C
15 lines
506 B
Objective-C
#import "AnyPromise.h"
|
|
@import Dispatch;
|
|
@import Foundation.NSDate;
|
|
@import Foundation.NSValue;
|
|
|
|
/// @return A promise that fulfills after the specified duration.
|
|
AnyPromise *PMKAfter(NSTimeInterval duration) {
|
|
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
|
|
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC));
|
|
dispatch_after(time, dispatch_get_global_queue(0, 0), ^{
|
|
resolve(@(duration));
|
|
});
|
|
}];
|
|
}
|