Skip to content

Commit 658f44f

Browse files
committed
refactor: update initialize method in ReactIterableAPI to simplify API and improve logging; adjust Objective-C bridge accordingly
1 parent cd350d4 commit 658f44f

3 files changed

Lines changed: 39 additions & 29 deletions

File tree

ios/RNIterableAPI/RNIterableAPI.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ - (void)hello {
3333
[(ReactIterableAPI *)_swiftAPI hello];
3434
}
3535

36-
// - (void)initializeWithApiKey:(NSString *)apiKey
37-
// config:(NSDictionary *)config
38-
// {
39-
// NSLog(@"initializeWithApiKey > Objective-C");
40-
// BOOL urlHandlerPresent = [config[@"urlHandlerPresent"] boolValue];
36+
- (void)initializeWithApiKey:(NSString *)apiKey
37+
config:(NSDictionary *)config
38+
{
39+
NSLog(@"initializeWithApiKey > Objective-C");
40+
BOOL urlHandlerPresent = [config[@"urlHandlerPresent"] boolValue];
4141

42-
// [_swiftAPI initializeWithApiKey:apiKey config:config];
43-
// }
42+
[_swiftAPI initializeWithApiKey:apiKey config:config];
43+
}
4444

4545
// - (void)initializeWithApiKey:(NSString *)apiKey
4646
// config:(NSDictionary *)config

ios/RNIterableAPI/ReactIterableAPI.swift

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,33 @@ open class ReactIterableAPI: RCTEventEmitter {
6868
print("Hello from Swift Again")
6969
}
7070

71-
@objc(initializeWithApiKey:config:version:resolver:rejecter:)
72-
func initialize(
73-
apiKey: String,
74-
config configDict: [AnyHashable: Any],
75-
version: String,
76-
resolver: @escaping RCTPromiseResolveBlock,
77-
rejecter: @escaping RCTPromiseRejectBlock
78-
) {
79-
ITBInfo()
80-
81-
initialize(
82-
withApiKey: apiKey,
83-
config: configDict,
84-
version: version,
85-
resolver: resolver,
86-
rejecter: rejecter)
87-
}
71+
@objc(initializeWithApiKey:config:)
72+
public func initializeWithApiKey(apiKey: String, config: NSDictionary) {
73+
NSLog("initialize called from swift")
74+
ITBInfo()
75+
76+
// self.initialize(
77+
// apiKey: apiKey
78+
// )
79+
}
80+
81+
// @objc(initializeWithApiKey:config:version:resolver:rejecter:)
82+
// public func initialize(
83+
// apiKey: String,
84+
// config configDict: [AnyHashable: Any],
85+
// version: String,
86+
// resolver: @escaping RCTPromiseResolveBlock,
87+
// rejecter: @escaping RCTPromiseRejectBlock
88+
// ) {
89+
// ITBInfo()
90+
91+
// initialize(
92+
// withApiKey: apiKey,
93+
// config: configDict,
94+
// version: version,
95+
// resolver: resolver,
96+
// rejecter: rejecter)
97+
// }
8898

8999
@objc(initialize2WithApiKey:config:apiEndPointOverride:version:resolver:rejecter:)
90100
func initialize2(

src/api/NativeRNIterableAPI.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export interface Spec extends TurboModule {
3030
// version: string
3131
// ): Promise<boolean>;
3232
// testing change
33-
// initializeWithApiKey(
34-
// apiKey: string,
35-
// config: IterableConfigDict,
36-
// version: string
37-
// ): void;
33+
initializeWithApiKey(
34+
apiKey: string,
35+
config: IterableConfigDict,
36+
version: string
37+
): void;
3838

3939
// initialize2WithApiKey(
4040
// apiKey: string,

0 commit comments

Comments
 (0)