UNPKG

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