RCTComponentViewRegistry.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/RCTComponentViewDescriptor.h>
  9. #import <React/RCTComponentViewFactory.h>
  10. #import <React/RCTComponentViewProtocol.h>
  11. #import <react/core/ReactPrimitives.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. * Registry of native component views.
  15. * Provides basic functionality for allocation, recycling, and querying (by tag) native view instances.
  16. */
  17. @interface RCTComponentViewRegistry : NSObject
  18. @property (nonatomic, strong, readonly) RCTComponentViewFactory *componentViewFactory;
  19. /**
  20. * Returns a descriptor referring to a native view instance from the recycle pool (or being created on demand)
  21. * for given `componentHandle` and with given `tag`.
  22. * #RefuseSingleUse
  23. */
  24. - (RCTComponentViewDescriptor)dequeueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
  25. tag:(facebook::react::Tag)tag;
  26. /**
  27. * Puts a given native component view to the recycle pool.
  28. * #RefuseSingleUse
  29. */
  30. - (void)enqueueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
  31. tag:(facebook::react::Tag)tag
  32. componentViewDescriptor:(RCTComponentViewDescriptor)componentViewDescriptor;
  33. /**
  34. * Returns a component view descriptor by given `tag`.
  35. */
  36. - (RCTComponentViewDescriptor const &)componentViewDescriptorWithTag:(facebook::react::Tag)tag;
  37. /**
  38. * Finds a native component view by given `tag`.
  39. * Returns `nil` if there is no registered component with the `tag`.
  40. */
  41. - (nullable UIView<RCTComponentViewProtocol> *)findComponentViewWithTag:(facebook::react::Tag)tag;
  42. /**
  43. * Creates a component view with a given type and puts it to the recycle pool.
  44. */
  45. - (void)optimisticallyCreateComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle;
  46. @end
  47. NS_ASSUME_NONNULL_END