Skip to content

Commit

Permalink
Remove unused life cycle event callbacks in ReactNativeHost (#4891)
Browse files Browse the repository at this point in the history
* Hook up life cycle events in ReactNativeHost

* Change files

* Remove life cycle events in ReactnativeHost

* Update change file
  • Loading branch information
kaiguo authored and NickGerleman committed May 14, 2020
1 parent 33c24f3 commit 614d03c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Remove unused lifecycle events in ReactNativeHost",
"packageName": "react-native-windows",
"email": "kaigu@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-05-13T19:53:42.358Z"
}
6 changes: 0 additions & 6 deletions vnext/Microsoft.ReactNative/ReactApplicationDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void ReactApplicationDelegate::OnActivated(IActivatedEventArgs const &args) noex
// Create the root view for the ReactNative app
UIElement ReactApplicationDelegate::OnCreate(hstring const &arguments) noexcept {
auto host = m_reactApplication.Host();
host.OnResume([=]() { m_application.Exit(); });

ApplyArguments(host, arguments.c_str());

Expand All @@ -106,28 +105,23 @@ UIElement ReactApplicationDelegate::OnCreate(hstring const &arguments) noexcept
}

void ReactApplicationDelegate::OnResuming(IInspectable const & /*sender*/, IInspectable const & /*args*/) noexcept {
m_reactApplication.Host().OnResume([=]() { m_application.Exit(); });

OutputDebugStringW(L"ReactApplicationDelegate::OnResuming");
}

void ReactApplicationDelegate::OnSuspending(IInspectable const & /*sender*/, IInspectable const & /*args*/) noexcept {
OutputDebugStringW(L"ReactApplicationDelegate::OnSuspending");
m_reactApplication.Host().OnSuspend();
}

void ReactApplicationDelegate::OnLeavingBackground(
IInspectable const & /*sender*/,
LeavingBackgroundEventArgs const & /*args*/) noexcept {
OutputDebugStringW(L"ReactApplicationDelegate::OnLeavingBackground");
m_reactApplication.Host().OnLeavingBackground();
}

void ReactApplicationDelegate::OnEnteredBackground(
IInspectable const & /*sender*/,
EnteredBackgroundEventArgs const & /*args*/) noexcept {
OutputDebugStringW(L"ReactApplicationDelegate::OnEnteredBackground");
m_reactApplication.Host().OnEnteredBackground();
}

} // namespace winrt::Microsoft::ReactNative::implementation
69 changes: 0 additions & 69 deletions vnext/Microsoft.ReactNative/ReactNativeHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,73 +122,4 @@ Mso::React::IReactHost *ReactNativeHost::ReactHost() noexcept {
return m_reactHost.Get();
}

// TODO: Create a LifeCycleStateMachine in constructor to raise events in response
// to events from the application and associate it with the ReactContext.
// Define the ILifecycleEventListener and add support to ReactContext to
// register a lifecycle listener. Define the IBackgroundEventListener and add
// support to ReactContext to register modules as background event listeners.

void ReactNativeHost::OnSuspend() noexcept {
OutputDebugStringW(L"TODO: ReactNativeHost::OnSuspend not implemented");

// DispatcherHelpers.AssertOnDispatcher();

//_defaultBackButtonHandler = null;
//_suspendCancellation?.Dispose();

// if (_useDeveloperSupport)
//{
// _devSupportManager.IsEnabled = false;
//}

//_lifecycleStateMachine.OnSuspend();
}

void ReactNativeHost::OnEnteredBackground() noexcept {
OutputDebugStringW(L"TODO: ReactNativeHost::OnEnteredBackground not implemented");

// DispatcherHelpers.AssertOnDispatcher();
//_lifecycleStateMachine.OnEnteredBackground();
}

void ReactNativeHost::OnLeavingBackground() noexcept {
OutputDebugStringW(L"TODO: ReactNativeHost::OnLeavingBackground not implemented");

// DispatcherHelpers.AssertOnDispatcher();
//_lifecycleStateMachine.OnLeavingBackground();
}

void ReactNativeHost::OnResume(OnResumeAction const & /*action*/) noexcept {
OutputDebugStringW(L"TODO: ReactNativeHost::OnResume not implemented");

// see the ReactInstanceManager.cs from the C# implementation

//_defaultBackButtonHandler = onBackPressed;
//_suspendCancellation = new CancellationDisposable();

// if (_useDeveloperSupport)
//{
// _devSupportManager.IsEnabled = true;
//}

//_lifecycleStateMachine.OnResume();
}

void ReactNativeHost::OnBackPressed() noexcept {
OutputDebugStringW(L"TODO: ReactNativeHost::OnBackPressed not implemented");

// DispatcherHelpers.AssertOnDispatcher();
// var reactContext = _currentReactContext;
// if (reactContext == null)
//{
// RnLog.Warn(ReactConstants.RNW, $"ReactInstanceManager: OnBackPressed:
// Instance detached from instance manager.");
// InvokeDefaultOnBackPressed();
//}
// else
//{
// reactContext.GetNativeModule<DeviceEventManagerModule>().EmitHardwareBackPressed();
//}
}

} // namespace winrt::Microsoft::ReactNative::implementation
6 changes: 0 additions & 6 deletions vnext/Microsoft.ReactNative/ReactNativeHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ struct ReactNativeHost : ReactNativeHostT<ReactNativeHost> {

void ReloadInstance() noexcept;

void OnSuspend() noexcept;
void OnEnteredBackground() noexcept;
void OnLeavingBackground() noexcept;
void OnResume(OnResumeAction const &action) noexcept;
void OnBackPressed() noexcept;

public:
Mso::React::IReactHost *ReactHost() noexcept;

Expand Down
6 changes: 0 additions & 6 deletions vnext/Microsoft.ReactNative/ReactNativeHost.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@ namespace Microsoft.ReactNative {
ReactInstanceSettings InstanceSettings { get; set; };

void ReloadInstance();

void OnSuspend();
void OnEnteredBackground();
void OnLeavingBackground();
void OnResume(OnResumeAction action);
void OnBackPressed();
}
} // namespace Microsoft.ReactNative

0 comments on commit 614d03c

Please sign in to comment.