1 /** 2 * Copyright (c) Facebook, Inc. and its affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8 #import <Foundation/Foundation.h> 9 10 NS_ASSUME_NONNULL_BEGIN 11 12 typedef void (^RNCAsyncStorageCompletion)(NSError *_Nullable error); 13 typedef void (^RNCAsyncStorageResultCallback)(NSArray<id<NSObject>> *valuesOrErrors); 14 15 @protocol RNCAsyncStorageDelegate <NSObject> 16 17 /*! 18 * Returns all keys currently stored. If none, an empty array is returned. 19 * @param block Block to call with result. 20 */ 21 - (void)allKeys:(RNCAsyncStorageResultCallback)block; 22 23 /*! 24 * Merges values with the corresponding values stored at specified keys. 25 * @param values Values to merge. 26 * @param keys Keys to the values that should be merged with. 27 * @param block Block to call with merged result. 28 */ 29 - (void)mergeValues:(NSArray<NSString *> *)values 30 forKeys:(NSArray<NSString *> *)keys 31 completion:(RNCAsyncStorageResultCallback)block; 32 33 /*! 34 * Removes all values from the store. 35 * @param block Block to call with result. 36 */ 37 - (void)removeAllValues:(RNCAsyncStorageCompletion)block; 38 39 /*! 40 * Removes all values associated with specified keys. 41 * @param keys Keys of values to remove. 42 * @param block Block to call with result. 43 */ 44 - (void)removeValuesForKeys:(NSArray<NSString *> *)keys 45 completion:(RNCAsyncStorageResultCallback)block; 46 47 /*! 48 * Sets specified key-value pairs. 49 * @param values Values to set. 50 * @param keys Keys of specified values to set. 51 * @param block Block to call with result. 52 */ 53 - (void)setValues:(NSArray<NSString *> *)values 54 forKeys:(NSArray<NSString *> *)keys 55 completion:(RNCAsyncStorageResultCallback)block; 56 57 /*! 58 * Returns values associated with specified keys. 59 * @param keys Keys of values to return. 60 * @param block Block to call with result. 61 */ 62 - (void)valuesForKeys:(NSArray<NSString *> *)keys completion:(RNCAsyncStorageResultCallback)block; 63 64 @optional 65 66 /*! 67 * Returns whether the delegate should be treated as a passthrough. 68 */ 69 @property (nonatomic, readonly, getter=isPassthrough) BOOL passthrough; 70 71 @end 72 73 NS_ASSUME_NONNULL_END 74