Add PromiseKit dependency

- Added PromiseKit dependency
This commit is contained in:
2018-11-15 22:08:00 -04:00
parent 2689d86c18
commit be7b6b5881
541 changed files with 46282 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
//
// CALayer+AnyPromise.h
//
// Created by María Patricia Montalvo Dzib on 24/11/14.
// Copyright (c) 2014 Aluxoft SCP. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import <PromiseKit/AnyPromise.h>
/**
To import the `CALayer` category:
use_frameworks!
pod "PromiseKit/QuartzCore"
Or `CALayer` is one of the categories imported by the umbrella pod:
use_frameworks!
pod "PromiseKit"
And then in your sources:
@import PromiseKit;
*/
@interface CALayer (PromiseKit)
/**
Add the specified animation object to the layers render tree.
@return A promise that thens two parameters:
1. `@YES` if the animation progressed entirely to completion.
2. The `CAAnimation` object.
@see addAnimation:forKey
*/
- (AnyPromise *)promiseAnimation:(CAAnimation *)animation forKey:(NSString *)key;
@end

View File

@@ -0,0 +1,36 @@
//
// CALayer+PromiseKit.m
//
// Created by María Patricia Montalvo Dzib on 24/11/14.
// Copyright (c) 2014 Aluxoft SCP. All rights reserved.
//
#import <QuartzCore/CAAnimation.h>
#import "CALayer+AnyPromise.h"
@interface PMKCAAnimationDelegate : NSObject <CAAnimationDelegate> {
@public
PMKResolver resolve;
CAAnimation *animation;
}
@end
@implementation PMKCAAnimationDelegate
- (void)animationDidStop:(CAAnimation *)ignoreOrRetainCycleHappens finished:(BOOL)flag {
resolve(PMKManifold(@(flag), animation));
animation.delegate = nil;
}
@end
@implementation CALayer (PromiseKit)
- (AnyPromise *)promiseAnimation:(CAAnimation *)animation forKey:(NSString *)key {
PMKCAAnimationDelegate *d = animation.delegate = [PMKCAAnimationDelegate new];
d->animation = animation;
[self addAnimation:animation forKey:key];
return [[AnyPromise alloc] initWithResolver:&d->resolve];
}
@end

View File

@@ -0,0 +1 @@
#import "CALayer+AnyPromise.h"