-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ReactInstanceManager): Support awaitable ReactContext #1458
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1458 +/- ##
==========================================
- Coverage 31.54% 31.47% -0.08%
==========================================
Files 266 266
Lines 19253 19296 +43
Branches 1599 1613 +14
==========================================
Hits 6073 6073
- Misses 13030 13072 +42
- Partials 150 151 +1
Continue to review full report at Codecov.
|
aab8588
to
af1b893
Compare
@@ -0,0 +1,32 @@ | |||
using ReactNative.Bridge; | |||
using ReactNative.DevSupport; | |||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete unused usings. #Closed
@@ -110,7 +111,7 @@ public void StartReactApplication(ReactInstanceManager reactInstanceManager, str | |||
|
|||
if (!_reactInstanceManager.HasStartedCreatingInitialContext) | |||
{ | |||
_reactInstanceManager.CreateReactContextInBackground(); | |||
_reactInstanceManager.CreateReactContextAsync(CancellationToken.None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateReactContextAsync [](start = 38, length = 23)
Likely has a warning, will need to await the task. #Closed
{ | ||
var moved = false; | ||
#if WINDOWS_UWP | ||
var temporaryFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(JSBundleFileName, CreationCollisionOption.GenerateUniqueName); | ||
var temporaryFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(JSBundleFileName, CreationCollisionOption.GenerateUniqueName).AsTask(token); | ||
try | ||
{ | ||
using (var stream = await temporaryFile.OpenStreamForWriteAsync()) | ||
{ | ||
await _devServerHelper.DownloadBundleFromUrlAsync(_jsAppBundleName, stream, token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DownloadBundleFromUrlAsync [](start = 43, length = 26)
Add ConfigureAwaits #Closed
await temporaryFile.MoveAsync( | ||
ApplicationData.Current.LocalFolder, | ||
JSBundleFileName, | ||
NameCollisionOption.ReplaceExisting).AsTask(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AsTask [](start = 57, length = 6)
Add comment about why CancellationToken not used here. #Closed
|
||
return await _reactInstanceCommandsHandler.CreateReactContextWithRemoteDebuggerAsync(factory, token); | ||
} | ||
finally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally [](start = 12, length = 7)
May need to catch some exceptions here... #Closed
@@ -110,7 +111,7 @@ public void StartReactApplication(ReactInstanceManager reactInstanceManager, str | |||
|
|||
if (!_reactInstanceManager.HasStartedCreatingInitialContext) | |||
{ | |||
_reactInstanceManager.CreateReactContextInBackground(); | |||
_reactInstanceManager.CreateReactContextAsync(CancellationToken.None); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetOrCreate #Closed
Currently, the ReactInstanceManager kicks off the process to create the ReactContext in the background and its not awaitable. This ensures a single asynchronous thread is available from start to finish for ReactContext creation. Fixes microsoft#1448
Currently, the ReactInstanceManager kicks off the process to create the ReactContext in the background and its not awaitable. This ensures a single asynchronous thread is available from start to finish for ReactContext creation.
Fixes #1448