Skip to content

Commit

Permalink
Refactor ReactSurface to use TaskInterface (facebook#38081)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#38081

Changelog: [Internal]

As part of refactoring ReactSurface, ensuring the methods expose interfaces instead of internal classes, e.g. use TaskInterface instead of Task,

Reviewed By: cortinico

Differential Revision: D47026648

fbshipit-source-id: 5fc42693b307af057b51a869133c52de0b1dca3a
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Jun 28, 2023
1 parent 04af0b9 commit 15d735b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ public SurfaceHandler getSurfaceHandler() {
return mSurfaceView.get();
}

public Task<Void> prerender() {
@Override
public TaskInterface prerender() {
ReactHost host = mReactHost.get();
if (host == null) {
return Task.forError(
Expand All @@ -164,7 +165,8 @@ public TaskInterface start() {
return host.startSurface(this);
}

public Task<Void> stop() {
@Override
public TaskInterface stop() {
ReactHost host = mReactHost.get();
if (host == null) {
return Task.forError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ interface ReactSurfaceInterface {
// the API of this interface will be completed as we analyze and refactor API of ReactSurface,
// ReactRootView, etc.

// Prerender this surface
fun prerender(): TaskInterface

// Start running this surface
fun start(): TaskInterface

// Stop running this surface
fun stop(): TaskInterface

// Get React root view of this surface
fun getView(): ViewGroup?
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testAttachThrowExeption() {
@Test
public void testPrerender() throws InterruptedException {
mReactSurface.attach(mReactHost);
Task<Void> task = mReactSurface.prerender();
Task<Void> task = (Task<Void>) mReactSurface.prerender();
task.waitForCompletion();

verify(mReactHost).prerenderSurface(mReactSurface);
Expand All @@ -102,7 +102,7 @@ public void testStop() throws InterruptedException {
Task<Void> task = (Task<Void>) mReactSurface.start();
task.waitForCompletion();

task = mReactSurface.stop();
task = (Task<Void>) mReactSurface.stop();
task.waitForCompletion();

verify(mReactHost).stopSurface(mReactSurface);
Expand Down Expand Up @@ -152,7 +152,8 @@ public void testStartStopHandlerCalls() throws InterruptedException {

assertThat(mReactSurface.isRunning()).isTrue();

mReactSurface.stop().waitForCompletion();
task = (Task<Void>) mReactSurface.stop();
task.waitForCompletion();

assertThat(mReactSurface.isRunning()).isFalse();
}
Expand Down

0 comments on commit 15d735b

Please sign in to comment.