Skip to content

Commit

Permalink
Merge pull request #31 from pinterest/fixImportWarnings
Browse files Browse the repository at this point in the history
Fixes up some import warnings
  • Loading branch information
garrettmoon authored Apr 14, 2022
2 parents ba60d97 + ad82443 commit 689ec2e
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 111 deletions.
3 changes: 1 addition & 2 deletions PINFuture/Classes/Categories/NSURLSession+PINFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#import <Foundation/Foundation.h>
#import <Foundation/NSURLSession.h>

#import "PINNSURLSessionDataTaskAndResult.h"
#import "PINFuture.h"
#import <PINFuture/PINNSURLSessionDataTaskAndResult.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
1 change: 1 addition & 0 deletions PINFuture/Classes/Categories/NSURLSession+PINFuture.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "NSURLSession+PINFuture.h"
#import "PINFutureDefinition.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
5 changes: 2 additions & 3 deletions PINFuture/Classes/Categories/PHImageManager+PINFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
// Copyright © 2016 Pinterest. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Photos/Photos.h>

#import "PINFuture.h"
#import "PINPHImageManagerImageDataResult.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINPHImageManagerImageDataResult.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
//
//

#import <Foundation/Foundation.h>

#import "PINFuture.h"
#import "PINNSURLSessionDataTaskResult.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINNSURLSessionDataTaskResult.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion PINFuture/Classes/PINCancelToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import <Foundation/Foundation.h>

#import "PINExecutor.h"
#import <PINFuture/PINExecutor.h>

typedef dispatch_block_t PINCancellationBlock;

Expand Down
5 changes: 2 additions & 3 deletions PINFuture/Classes/PINFuture+ChainSideEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
// Copyright (c) 2017 Pinterest. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
4 changes: 1 addition & 3 deletions PINFuture/Classes/PINFuture+Completion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// Copyright (c) 2017 Pinterest. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
4 changes: 1 addition & 3 deletions PINFuture/Classes/PINFuture+Delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// Created by Chris Danford on 4/16/18.
//

#import "PINFuture.h"

#import "PINFuture+MapToValue.h"
#import <PINFuture/PINFuture+MapToValue.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
3 changes: 2 additions & 1 deletion PINFuture/Classes/PINFuture+Dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright (c) 2016 Pinterest. All rights reserved.
//

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
3 changes: 2 additions & 1 deletion PINFuture/Classes/PINFuture+FlatMapError.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright (c) 2016 Pinterest. All rights reserved.
//

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>

@interface PINFuture<ObjectType> (FlatMapError)

Expand Down
1 change: 0 additions & 1 deletion PINFuture/Classes/PINFuture+GatherAll.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

#import <Foundation/Foundation.h>
#import "PINFuture.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
4 changes: 2 additions & 2 deletions PINFuture/Classes/PINFuture+GatherSome.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//

#import <Foundation/Foundation.h>
#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 2 additions & 0 deletions PINFuture/Classes/PINFuture+GatherSome.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

#import "PINFuture+GatherSome.h"
#import "PINFuture+MapError.h"
#import "PINFuture+GatherAll.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
6 changes: 3 additions & 3 deletions PINFuture/Classes/PINFuture+Generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//

#import <Foundation/Foundation.h>

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>
#import <PINFuture/PINFutureMap.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
5 changes: 5 additions & 0 deletions PINFuture/Classes/PINFuture+Generated.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
//

#import "PINFuture+Generated.h"
#import "PINFuture+Completion.h"
#import "PINFuture+Dispatch.h"
#import "PINFuture+ChainSideEffect.h"
#import "PINFutureMap+Map.h"
#import "PINFutureMap+FlatMap.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
3 changes: 2 additions & 1 deletion PINFuture/Classes/PINFuture+MapError.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright (c) 2016 Pinterest. All rights reserved.
//

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>

@interface PINFuture<ObjectType> (MapError)

Expand Down
2 changes: 2 additions & 0 deletions PINFuture/Classes/PINFuture+MapError.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import "PINFuture+MapError.h"

#import "PINFuture+FlatMapError.h"

@implementation PINFuture (MapError)

- (PINFuture<id> *)executor:(id<PINExecutor>)executor mapError:(id (^)(NSError *error))mapError
Expand Down
3 changes: 2 additions & 1 deletion PINFuture/Classes/PINFuture+MapToValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright (c) 2016 Pinterest. All rights reserved.
//

#import "PINFuture.h"
#import <PINFuture/PINDefines.h>
#import <PINFuture/PINFutureDefinition.h>

@interface PINFuture<ObjectType> (MapToValue)

Expand Down
2 changes: 1 addition & 1 deletion PINFuture/Classes/PINFuture+MapToValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "PINFuture+MapToValue.h"

#import "PINFutureMap.h"
#import "PINFutureMap+Map.h"

@implementation PINFuture (MapToValue)

Expand Down
4 changes: 1 addition & 3 deletions PINFuture/Classes/PINFuture+NoValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// Created by Chris Danford on 4/16/18.
//

#import <Foundation/Foundation.h>

#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>

/**
* A Future that has no meaningful value. Technically, it does have a value (an NSNull).
Expand Down
91 changes: 24 additions & 67 deletions PINFuture/Classes/PINFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,27 @@

#import <Foundation/Foundation.h>

#import "PINExecutor.h"
#import "PINDefines.h"

NS_ASSUME_NONNULL_BEGIN

/**
* A super-simple future implementation.
* This is a pure objective C implementation that:
* - is thread-safe
* - preserves type safety as much as possible
*
* Non-goals:
* - Don't catch Exceptions in callbacks like Promises/A+. On this platform, Exceptions are generally fatal
* and Errors aren't.
*
* Future improvement ideas:
* - Support progress and cancellation.
*/
@interface PINFuture<__covariant ObjectType> : NSObject

- (instancetype)init NS_UNAVAILABLE;

/**
* Return a future that is immediately resolved.
*/
+ (PINFuture<ObjectType> *)withValue:(ObjectType)value PIN_WARN_UNUSED_RESULT;

/**
* Return a future that is immediately rejected.
*/
+ (PINFuture<ObjectType> *)withError:(NSError *)error PIN_WARN_UNUSED_RESULT;

/**
* Construct a future from a block that eventually calls resolve or reject.
* This is slightly dangerous and should only be used when adapting from callbacks to a Future because there's no compiler enforcement
* that all paths of your block will eventually call either `resolve` or `reject`.
*/
+ (PINFuture<ObjectType> *)withBlock:(void(^)(void(^resolve)(ObjectType), void(^reject)(NSError *)))block PIN_WARN_UNUSED_RESULT;

#pragma mark - attach callbacks

/**
* Execute a block on success or on failure. Use this if you want to have a side-effect and nothing
* needs to wait on your side-effect to complete.
*/
- (void)executor:(id<PINExecutor>)executor success:(nullable void(^)(ObjectType value))success failure:(nullable void(^)(NSError *error))failure;

@end

NS_ASSUME_NONNULL_END

// Import everything for caller convenience.
#import "PINFuture+ChainSideEffect.h"
#import "PINFuture+Completion.h"
#import "PINFuture+Delay.h"
#import "PINFuture+Dispatch.h"
#import "PINFuture+FlatMapError.h"
#import "PINFuture+GatherAll.h"
#import "PINFuture+GatherSome.h"
#import "PINFuture+MapError.h"
#import "PINFuture+MapToValue.h"
#import "PINFutureMap.h"
#import "PINFutureMap+Map.h"
#import "PINFuture+NoValue.h"
#import "PINFutureMap+FlatMap.h"
#import "PINFuturePending.h"
#import "PINFuture+Generated.h"
#import <PINFuture/PINExecutor.h>
#import <PINFuture/PINDefines.h>
#import <PINFuture/PINFuture+ChainSideEffect.h>
#import <PINFuture/PINFuture+Completion.h>
#import <PINFuture/PINFuture+Delay.h>
#import <PINFuture/PINFuture+Dispatch.h>
#import <PINFuture/PINFuture+FlatMapError.h>
#import <PINFuture/PINFuture+GatherAll.h>
#import <PINFuture/PINFuture+GatherSome.h>
#import <PINFuture/PINFuture+MapError.h>
#import <PINFuture/PINFuture+MapToValue.h>
#import <PINFuture/PINFutureMap.h>
#import <PINFuture/PINFutureMap+Map.h>
#import <PINFuture/PINFuture+NoValue.h>
#import <PINFuture/PINFutureMap+FlatMap.h>
#import <PINFuture/PINFuturePending.h>
#import <PINFuture/PINFuture+Generated.h>
#import <PINFuture/PINFutureAndCancelToken.h>
#import <PINFuture/NSURLSession+PINFuture.h>
#import <PINFuture/PINNSURLSessionDataTaskResult.h>
#import <PINFuture/PINNSURLSessionDataTaskAndResult.h>
#import <PINFuture/PHImageManager+PINFuture.h>
#import <PINFuture/PINFutureOnce.h>
#import <PINFuture/PINFutureError.h>
7 changes: 3 additions & 4 deletions PINFuture/Classes/PINFutureAndCancelToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
// Created by Chris Danford on 1/16/17.
//

#import <Foundation/Foundation.h>

#import "PINCancelToken.h"
#import "PINFuture.h"
#import <PINFuture/PINFutureDefinition.h>
#import <PINFuture/PINDefines.h>
#import <PINFuture/PINCancelToken.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
61 changes: 61 additions & 0 deletions PINFuture/Classes/PINFutureDefinition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// PINFutureDefinition.h
// Copyright © 2022-present, Pinterest, Inc. All rights reserved.
//

#ifndef PINFutureDefinition_h
#define PINFutureDefinition_h

#import <PINFuture/PINExecutor.h>
#import <PINFuture/PINDefines.h>

NS_ASSUME_NONNULL_BEGIN

/**
* A super-simple future implementation.
* This is a pure objective C implementation that:
* - is thread-safe
* - preserves type safety as much as possible
*
* Non-goals:
* - Don't catch Exceptions in callbacks like Promises/A+. On this platform, Exceptions are generally fatal
* and Errors aren't.
*
* Future improvement ideas:
* - Support progress and cancellation.
*/
@interface PINFuture<__covariant ObjectType> : NSObject

- (instancetype)init NS_UNAVAILABLE;

/**
* Return a future that is immediately resolved.
*/
+ (PINFuture<ObjectType> *)withValue:(ObjectType)value PIN_WARN_UNUSED_RESULT;

/**
* Return a future that is immediately rejected.
*/
+ (PINFuture<ObjectType> *)withError:(NSError *)error PIN_WARN_UNUSED_RESULT;

/**
* Construct a future from a block that eventually calls resolve or reject.
* This is slightly dangerous and should only be used when adapting from callbacks to a Future because there's no compiler enforcement
* that all paths of your block will eventually call either `resolve` or `reject`.
*/
+ (PINFuture<ObjectType> *)withBlock:(void(^)(void(^resolve)(ObjectType), void(^reject)(NSError *)))block PIN_WARN_UNUSED_RESULT;

#pragma mark - attach callbacks

/**
* Execute a block on success or on failure. Use this if you want to have a side-effect and nothing
* needs to wait on your side-effect to complete.
*/
- (void)executor:(id<PINExecutor>)executor success:(nullable void(^)(ObjectType value))success failure:(nullable void(^)(NSError *error))failure;

@end

NS_ASSUME_NONNULL_END


#endif /* PINFutureDefinition_h */
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016 Pinterest. All rights reserved.
//

#import "PINFuture.h"
#import "PINFutureDefinition.h"

#import "PINExecutor.h"
#import "PINFutureMap+Map.h"
Expand Down
Loading

0 comments on commit 689ec2e

Please sign in to comment.