From 53858ceaa3beab02726b1bd6e125e506477d445e Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Tue, 17 Nov 2020 14:47:55 -0800 Subject: [PATCH] Add reset method to RCTFabricSurface [2/N] Summary: This method allows a surface to re-render from scratch, without having to delete and reinstantiate the surface. Changelog: [iOS] Added reset method to RCTFabricSurface to help with reloads Reviewed By: RSNara Differential Revision: D25000509 fbshipit-source-id: f74170aa78cc84491ad2679f130ed3c8965bbe34 --- React/Fabric/Surface/RCTFabricSurface.h | 7 +++++++ React/Fabric/Surface/RCTFabricSurface.mm | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/React/Fabric/Surface/RCTFabricSurface.h b/React/Fabric/Surface/RCTFabricSurface.h index d4dd93c9119..1c3e4af43f7 100644 --- a/React/Fabric/Surface/RCTFabricSurface.h +++ b/React/Fabric/Surface/RCTFabricSurface.h @@ -70,6 +70,13 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)start; - (BOOL)stop; +/** + * EXPERIMENTAL + * Reset's the Surface to it's initial stage. + * It uses the passed in surface presenter, and whatever else was passed in init. + */ +- (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter; + #pragma mark - Layout: Setting the size constrains /** diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index 35368dada39..993985c4846 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -64,6 +64,13 @@ using namespace facebook::react; return self; } +- (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter +{ + _surfacePresenter = surfacePresenter; + _stage = RCTSurfaceStageSurfaceDidInitialize; + _view = nil; +} + - (BOOL)start { if (![self _setStage:RCTSurfaceStageStarted]) {