@@ -231,7 +231,7 @@ public LifecycleState getLifecycleState() {
231
231
*/
232
232
@ Override
233
233
public TaskInterface <Void > start () {
234
- return Task .call (this ::getOrCreateStartTask , mBGExecutor ). continueWithTask ( Task :: getResult ) ;
234
+ return Task .call (this ::getOrCreateStartTask , mBGExecutor );
235
235
}
236
236
237
237
/** Initialize and run a React Native surface in a background without mounting real views. */
@@ -488,37 +488,36 @@ public void removeReactInstanceEventListener(ReactInstanceEventListener listener
488
488
public TaskInterface <Void > reload (String reason ) {
489
489
final String method = "reload()" ;
490
490
return Task .call (
491
- () -> {
492
- Task <Void > reloadTask = null ;
493
- if (mDestroyTask != null ) {
494
- log (method , "Waiting for destroy to finish, before reloading React Native." );
495
- reloadTask =
496
- mDestroyTask
497
- .continueWithTask (task -> getOrCreateReloadTask (reason ), mBGExecutor )
498
- .makeVoid ();
499
- } else {
500
- reloadTask = getOrCreateReloadTask (reason ).makeVoid ();
501
- }
491
+ () -> {
492
+ Task <Void > reloadTask = null ;
493
+ if (mDestroyTask != null ) {
494
+ log (method , "Waiting for destroy to finish, before reloading React Native." );
495
+ reloadTask =
496
+ mDestroyTask
497
+ .continueWithTask (task -> getOrCreateReloadTask (reason ), mBGExecutor )
498
+ .makeVoid ();
499
+ } else {
500
+ reloadTask = getOrCreateReloadTask (reason ).makeVoid ();
501
+ }
502
502
503
- return reloadTask .continueWithTask (
504
- task -> {
505
- if (task .isFaulted ()) {
506
- final Exception ex = task .getError ();
507
- Assertions .assertNotNull (ex , "Reload failed without an exception" );
508
- if (mUseDevSupport ) {
509
- mDevSupportManager .handleException (ex );
510
- } else {
511
- mReactHostDelegate .handleInstanceException (ex );
512
- }
513
- return getOrCreateDestroyTask ("Reload failed" , ex );
514
- }
503
+ return reloadTask .continueWithTask (
504
+ task -> {
505
+ if (task .isFaulted ()) {
506
+ final Exception ex = task .getError ();
507
+ Assertions .assertNotNull (ex , "Reload failed without an exception" );
508
+ if (mUseDevSupport ) {
509
+ mDevSupportManager .handleException (ex );
510
+ } else {
511
+ mReactHostDelegate .handleInstanceException (ex );
512
+ }
513
+ return getOrCreateDestroyTask ("Reload failed" , ex );
514
+ }
515
515
516
- return task ;
517
- },
518
- mBGExecutor );
519
- },
520
- mBGExecutor )
521
- .continueWithTask (Task ::getResult );
516
+ return task ;
517
+ },
518
+ mBGExecutor );
519
+ },
520
+ mBGExecutor );
522
521
}
523
522
524
523
@ DoNotStrip
@@ -601,19 +600,18 @@ public Void then(Task<Void> task) throws Exception {
601
600
public TaskInterface <Void > destroy (String reason , @ Nullable Exception ex ) {
602
601
final String method = "destroy()" ;
603
602
return Task .call (
604
- () -> {
605
- if (mReloadTask != null ) {
606
- log (
607
- method ,
608
- "Reloading React Native. Waiting for reload to finish before destroying React"
609
- + " Native." );
610
- return mReloadTask .continueWithTask (
611
- task -> getOrCreateDestroyTask (reason , ex ), mBGExecutor );
612
- }
613
- return getOrCreateDestroyTask (reason , ex );
614
- },
615
- mBGExecutor )
616
- .continueWithTask (Task ::getResult );
603
+ () -> {
604
+ if (mReloadTask != null ) {
605
+ log (
606
+ method ,
607
+ "Reloading React Native. Waiting for reload to finish before destroying React"
608
+ + " Native." );
609
+ return mReloadTask .continueWithTask (
610
+ task -> getOrCreateDestroyTask (reason , ex ), mBGExecutor );
611
+ }
612
+ return getOrCreateDestroyTask (reason , ex );
613
+ },
614
+ mBGExecutor );
617
615
}
618
616
619
617
private MemoryPressureListener createMemoryPressureListener (ReactInstance reactInstance ) {
@@ -1111,8 +1109,7 @@ private BridgelessReactContext getOrCreateReactContext() {
1111
1109
* destroying, will wait until destroy is finished, before creating.
1112
1110
*/
1113
1111
private Task <ReactInstance > getOrCreateReactInstance () {
1114
- return Task .call (this ::waitThenCallGetOrCreateReactInstanceTask , mBGExecutor )
1115
- .continueWithTask (Task ::getResult );
1112
+ return Task .call (this ::waitThenCallGetOrCreateReactInstanceTask , mBGExecutor );
1116
1113
}
1117
1114
1118
1115
@ ThreadConfined ("ReactHost" )
0 commit comments