Skip to content

Commit 2948130

Browse files
committed
Allow passthrough.
1 parent 772aa71 commit 2948130

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

ios/RNCAsyncStorage.m

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
357357
callback(@[RCTNullIfNil(errors), result]);
358358
}
359359

360+
- (BOOL)_passthroughDelegate
361+
{
362+
return [self.delegate respondsToSelector:@selector(isPassthrough)] && self.delegate.isPassthrough;
363+
}
364+
360365
#pragma mark - Exported JS Functions
361366

362367
RCT_EXPORT_METHOD(multiGet:(NSArray<NSString *> *)keys
@@ -380,7 +385,10 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
380385
}
381386
}];
382387
}];
383-
return;
388+
389+
if (![self _passthroughDelegate]) {
390+
return;
391+
}
384392
}
385393

386394
NSDictionary *errorOut = [self _ensureSetup];
@@ -409,7 +417,10 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
409417
NSArray<NSDictionary *> *errors = RCTMakeErrors(results);
410418
callback(@[RCTNullIfNil(errors)]);
411419
}];
412-
return;
420+
421+
if (![self _passthroughDelegate]) {
422+
return;
423+
}
413424
}
414425

415426
NSDictionary *errorOut = [self _ensureSetup];
@@ -443,7 +454,10 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
443454
NSArray<NSDictionary *> *errors = RCTMakeErrors(results);
444455
callback(@[RCTNullIfNil(errors)]);
445456
}];
446-
return;
457+
458+
if (![self _passthroughDelegate]) {
459+
return;
460+
}
447461
}
448462

449463
NSDictionary *errorOut = [self _ensureSetup];
@@ -487,7 +501,10 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
487501
NSArray<NSDictionary *> *errors = RCTMakeErrors(results);
488502
callback(@[RCTNullIfNil(errors)]);
489503
}];
490-
return;
504+
505+
if (![self _passthroughDelegate]) {
506+
return;
507+
}
491508
}
492509

493510
NSDictionary *errorOut = [self _ensureSetup];
@@ -543,7 +560,10 @@ - (void)_multiGet:(NSArray<NSString *> *)keys
543560
[self.delegate allKeys:^(NSArray<id<NSObject>> *keys) {
544561
callback(@[(id)kCFNull, keys]);
545562
}];
546-
return;
563+
564+
if (![self _passthroughDelegate]) {
565+
return;
566+
}
547567
}
548568

549569
NSDictionary *errorOut = [self _ensureSetup];

ios/RNCAsyncStorageDelegate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ typedef void (^RNCAsyncStorageResultCallback)(NSArray<id<NSObject>> * valuesOrEr
3232
- (void)valuesForKeys:(NSArray<NSString *> *)keys
3333
completion:(RNCAsyncStorageResultCallback)block;
3434

35+
@optional
36+
37+
@property (nonatomic, readonly, getter=isPassthrough) BOOL passthrough;
38+
3539
@end
3640

3741
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)