Skip to content

Commit

Permalink
Pass RCTSurfacePresenter into RCTNativeAnimatedNodesManager in bridge…
Browse files Browse the repository at this point in the history
…less

Summary:
This diff ties the stack together. It completes the long chain of RCTSurfacePresenter ownership:

`FBReactModule` -> `RCTNativeAnimatedTurboModule` (this diff and D23272746)
`RCTNativeAnimatedTurboModule` -> `RCTNativeAnimatedNodesManager` (this diff)
`RCTNativeAnimatedNodesManager` -> `RCTPropsAnimatedNode` (D23272735)

It completes animations working without the bridge.

Changelog: [Internal]

Differential Revision: D23272755

fbshipit-source-id: 137f7ff89993a2cb644bd67869eb685afcec4068
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Aug 24, 2020
1 parent 700960c commit 75197db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libraries/NativeAnimation/RCTNativeAnimatedModule.mm
Expand Up @@ -8,6 +8,7 @@
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTNativeAnimatedModule.h>
#import <React/RCTNativeAnimatedNodesManager.h>
#import <React/RCTLog.h>

#import <RCTTypeSafety/RCTConvertHelpers.h>

Expand Down Expand Up @@ -68,6 +69,14 @@ - (void)setBridge:(RCTBridge *)bridge
[bridge.surfacePresenter addObserver:self];
}

/*
* This selector should only be invoked in bridgeless mode, which is not compatible with this non turbo module.
*/
- (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{
RCTLogWarn(@"setSurfacePresenter should only be invoked in RCTNativeAnimatedTurboModule");
}

#pragma mark -- API

RCT_EXPORT_METHOD(createAnimatedNode:(double)tag
Expand Down
11 changes: 11 additions & 0 deletions Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm
Expand Up @@ -71,6 +71,17 @@ - (void)setBridge:(RCTBridge *)bridge
[_surfacePresenter addObserver:self];
}

/*
* In bridgeless mode, `setBridge` is never called during initializtion. Instead this selector is invoked via
* BridgelessTurboModuleSetup.
*/
- (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{
_surfacePresenter = surfacePresenter;
_nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:self.bridge surfacePresenter:_surfacePresenter];
[_surfacePresenter addObserver:self];
}

#pragma mark -- API

RCT_EXPORT_METHOD(startOperationBatch)
Expand Down

0 comments on commit 75197db

Please sign in to comment.