RCTImageStoreManager.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #import <UIKit/UIKit.h>
  8. #import <React/RCTBridge.h>
  9. #import <React/RCTURLRequestHandler.h>
  10. @interface RCTImageStoreManager : NSObject <RCTURLRequestHandler>
  11. /**
  12. * Set and get cached image data asynchronously. It is safe to call these from any
  13. * thread. The callbacks will be called on an unspecified thread.
  14. */
  15. - (void)removeImageForTag:(NSString *)imageTag withBlock:(void (^)(void))block;
  16. - (void)storeImageData:(NSData *)imageData withBlock:(void (^)(NSString *imageTag))block;
  17. - (void)getImageDataForTag:(NSString *)imageTag withBlock:(void (^)(NSData *imageData))block;
  18. /**
  19. * Convenience method to store an image directly (image is converted to data
  20. * internally, so any metadata such as scale or orientation will be lost).
  21. */
  22. - (void)storeImage:(UIImage *)image withBlock:(void (^)(NSString *imageTag))block;
  23. @end
  24. @interface RCTImageStoreManager (Deprecated)
  25. /**
  26. * These methods are deprecated - use the data-based alternatives instead.
  27. */
  28. - (NSString *)storeImage:(UIImage *)image __deprecated;
  29. - (UIImage *)imageForTag:(NSString *)imageTag __deprecated;
  30. - (void)getImageForTag:(NSString *)imageTag withBlock:(void (^)(UIImage *image))block __deprecated;
  31. @end
  32. @interface RCTBridge (RCTImageStoreManager)
  33. @property (nonatomic, readonly) RCTImageStoreManager *imageStoreManager;
  34. @end