File tree Expand file tree Collapse file tree 6 files changed +34
-4
lines changed
Expand file tree Collapse file tree 6 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ NS_ASSUME_NONNULL_BEGIN
4343 */
4444- (ReactTag)tagByComponentView : (UIView<RCTComponentViewProtocol> *)componentView ;
4545
46+ /* *
47+ * Creates a component view with a given type and puts it to the recycle pool.
48+ */
49+ - (void )preliminaryCreateComponentViewWithName : (NSString *)componentName ;
50+
4651@end
4752
4853NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ + (void)unregisterView:(UIView *)view
6464
6565#endif
6666
67- const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 256 ;
67+ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024 ;
6868
6969@implementation RCTComponentViewRegistry {
7070 NSMapTable <id , UIView<RCTComponentViewProtocol> *> *_registry;
@@ -121,6 +121,13 @@ - (void)enqueueComponentViewWithName:(NSString *)componentName
121121 [self _enqueueComponentViewWithName: componentName componentView: componentView];
122122}
123123
124+ - (void )preliminaryCreateComponentViewWithName : (NSString *)componentName
125+ {
126+ RCTAssertMainQueue ();
127+ [self _enqueueComponentViewWithName: componentName
128+ componentView: [self _createComponentViewWithName: componentName]];
129+ }
130+
124131- (UIView<RCTComponentViewProtocol> *)componentViewByTag : (ReactTag)tag
125132{
126133 RCTAssertMainQueue ();
Original file line number Diff line number Diff line change @@ -26,10 +26,18 @@ NS_ASSUME_NONNULL_BEGIN
2626/* *
2727 * Transfroms mutation insturctions to mount items and execute them.
2828 * The order of mutation tnstructions matters.
29+ * Can be called from any thread.
2930 */
3031- (void )mutateComponentViewTreeWithMutationInstructions : (facebook::react::TreeMutationInstructionList)instructions
3132 rootTag : (ReactTag)rootTag ;
3233
34+ /* *
35+ * Suggests preliminary creation of a component view of given type.
36+ * The receiver is free to ignore the request.
37+ * Can be called from any thread.
38+ */
39+ - (void )preliminaryCreateComponentViewWithName : (NSString *)componentName ;
40+
3341@end
3442
3543NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -181,4 +181,11 @@ - (void)_performMountItems:(NSArray<RCTMountItemProtocol> *)mountItems
181181 [self .delegate mountingManager: self didMountComponentsWithRootTag: rootTag];
182182}
183183
184+ - (void )preliminaryCreateComponentViewWithName : (NSString *)componentName
185+ {
186+ RCTExecuteOnMainQueue (^{
187+ [self ->_componentViewRegistry preliminaryCreateComponentViewWithName: componentName];
188+ });
189+ }
190+
184191@end
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
1919@class RCTMountingManager;
2020
2121/* *
22- * Exacly same semantic as `facebook::react::SchedulerDelegate`.
22+ * Exactly same semantic as `facebook::react::SchedulerDelegate`.
2323 */
2424@protocol RCTSchedulerDelegate
2525
Original file line number Diff line number Diff line change @@ -67,15 +67,18 @@ - (void)dealloc
6767 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
6868}
6969
70- - (void )schedulerDidComputeMutationInstructions : (facebook::react::TreeMutationInstructionList)instructions rootTag : (ReactTag)rootTag
70+ #pragma mark - RCTSchedulerDelegate
71+
72+ - (void )schedulerDidComputeMutationInstructions : (facebook::react::TreeMutationInstructionList)instructions
73+ rootTag : (ReactTag)rootTag
7174{
7275 [_mountingManager mutateComponentViewTreeWithMutationInstructions: instructions
7376 rootTag: rootTag];
7477}
7578
7679- (void )schedulerDidRequestPreliminaryViewAllocationWithComponentName : (NSString *)componentName
7780{
78- // TODO: To be implemeted.
81+ [_mountingManager preliminaryCreateComponentViewWithName: componentName];
7982}
8083
8184#pragma mark - Internal Surface-dedicated Interface
You can’t perform that action at this time.
0 commit comments