Skip to content

Commit

Permalink
fix(ios): have KrollPromise static methods return instancetype, not J…
Browse files Browse the repository at this point in the history
…SValue*
  • Loading branch information
sgtcoolguy committed Jan 26, 2021
1 parent 62ee5c5 commit de50c8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions iphone/TitaniumKit/TitaniumKit/Sources/Kroll/KrollPromise.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

- (KrollPromise *)initInContext:(JSContext *)context;

+ (JSValue *)resolved:(NSArray *)arguments inContext:(JSContext *)context;
+ (JSValue *)rejected:(NSArray *)arguments inContext:(JSContext *)context;
+ (KrollPromise *)resolved:(NSArray *)arguments inContext:(JSContext *)context;
+ (KrollPromise *)rejected:(NSArray *)arguments inContext:(JSContext *)context;
+ (KrollPromise *)rejectedWithErrorMessage:(NSString *)message inContext:(JSContext *)context;

@end

Expand Down
16 changes: 12 additions & 4 deletions iphone/TitaniumKit/TitaniumKit/Sources/Kroll/KrollPromise.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,26 @@ - (KrollPromise *)initInContext:(JSContext *)context
return self;
}

+ (JSValue *)resolved:(NSArray *)arguments inContext:(JSContext *)context
+ (KrollPromise *)resolved:(NSArray *)arguments inContext:(JSContext *)context
{
KrollPromise *promise = [[[KrollPromise alloc] initInContext:context] autorelease];
[promise resolve:arguments];
return promise.JSValue;
return promise;
}

+ (JSValue *)rejected:(NSArray *)arguments inContext:(JSContext *)context
+ (KrollPromise *)rejected:(NSArray *)arguments inContext:(JSContext *)context
{
KrollPromise *promise = [[[KrollPromise alloc] initInContext:context] autorelease];
[promise reject:arguments];
return promise.JSValue;
return promise;
}

+ (KrollPromise *)rejectedWithErrorMessage:(NSString *)message inContext:(JSContext *)context
{
KrollPromise *promise = [[[KrollPromise alloc] initInContext:context] autorelease];
JSValue *error = [JSValue valueWithNewErrorFromMessage:message inContext:context];
[promise reject:@[ error ]];
return promise;
}

- (void)resolve:(NSArray *)arguments
Expand Down

0 comments on commit de50c8c

Please sign in to comment.