public void SetContext(ReactContext _reactContext) { lock (_lifecycleStateLock) { if (_currentReactContext != _reactContext) { if (_currentReactContext != null) { // Suspend old context if needed. We don't touch the current lifecycle state. if (_lifecycleState == LifecycleState.Foreground || _lifecycleState == LifecycleState.Background) { if (_lifecycleState == LifecycleState.Foreground) { _currentReactContext.OnEnteredBackground(); } _currentReactContext.OnSuspend(); } } _currentReactContext = _reactContext; if (_currentReactContext != null) { // Bring new context in sync with current lifecycle state if (_lifecycleState == LifecycleState.Foreground || _lifecycleState == LifecycleState.Background) { _currentReactContext.OnResume(); if (_lifecycleState == LifecycleState.Foreground) { _currentReactContext.OnLeavingBackground(); } } } } } }
private void TearDownReactContext(ReactContext reactContext) { DispatcherHelpers.AssertOnDispatcher(); if (_lifecycleState == LifecycleState.Resumed) { reactContext.OnSuspend(); } foreach (var rootView in _attachedRootViews) { DetachViewFromInstance(rootView, reactContext.ReactInstance); } reactContext.Dispose(); _devSupportManager.OnReactContextDestroyed(reactContext); // TODO: add memory pressure hooks }
private async Task TearDownReactContextAsync(ReactContext reactContext) { DispatcherHelpers.AssertOnDispatcher(); if (_lifecycleState == LifecycleState.Resumed) { reactContext.OnSuspend(); } foreach (var rootView in _attachedRootViews) { rootView.Children.Clear(); rootView.ClearData(); } await reactContext.DisposeAsync(); _devSupportManager.OnReactContextDestroyed(reactContext); // TODO: add memory pressure hooks }
private async Task TearDownReactContextAsync(ReactContext reactContext) { DispatcherHelpers.AssertOnDispatcher(); if (_lifecycleState == LifecycleState.Resumed) { reactContext.OnSuspend(); } foreach (var rootView in _attachedRootViews) { DetachViewFromInstance(rootView, reactContext.ReactInstance); } await reactContext.DisposeAsync(); _devSupportManager.OnReactContextDestroyed(reactContext); // TODO: add memory pressure hooks }