RCTSurfaceRegistry.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/RCTPrimitives.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @class RCTFabricSurface;
  11. typedef void (^RCTSurfaceEnumeratorBlock)(NSEnumerator<RCTFabricSurface *> *enumerator);
  12. /**
  13. * Registry of Surfaces.
  14. * Incapsulates storing Surface objects and querying them by root tag.
  15. * All methods of the registry are thread-safe.
  16. * The registry stores Surface objects as weak references.
  17. */
  18. @interface RCTSurfaceRegistry : NSObject
  19. - (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block;
  20. /**
  21. * Adds Surface object into the registry.
  22. * The registry does not retain Surface references.
  23. */
  24. - (void)registerSurface:(RCTFabricSurface *)surface;
  25. /**
  26. * Removes Surface object from the registry.
  27. */
  28. - (void)unregisterSurface:(RCTFabricSurface *)surface;
  29. /**
  30. * Returns stored Surface object by given root tag.
  31. * If the registry does not have such Surface registered, returns `nil`.
  32. */
  33. - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
  34. @end
  35. NS_ASSUME_NONNULL_END