Skip to content

Commit

Permalink
Add reset method to RCTFabricSurface [2/N]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Nov 17, 2020
1 parent 3a0ed2e commit 53858ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions React/Fabric/Surface/RCTFabricSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
7 changes: 7 additions & 0 deletions React/Fabric/Surface/RCTFabricSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter
return self;
}

- (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter
{
_surfacePresenter = surfacePresenter;
_stage = RCTSurfaceStageSurfaceDidInitialize;
_view = nil;
}

- (BOOL)start
{
if (![self _setStage:RCTSurfaceStageStarted]) {
Expand Down

0 comments on commit 53858ce

Please sign in to comment.